Subash Abhinov Kasiviswanathan | 2139ce8a | 2016-10-14 11:01:48 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _RMNET_DATA_PRIVATE_H_ |
| 14 | #define _RMNET_DATA_PRIVATE_H_ |
| 15 | |
| 16 | #define RMNET_DATA_MAX_VND 32 |
| 17 | #define RMNET_DATA_MAX_PACKET_SIZE 16384 |
| 18 | #define RMNET_DATA_DFLT_PACKET_SIZE 1500 |
| 19 | #define RMNET_DATA_DEV_NAME_STR "rmnet_data" |
| 20 | #define RMNET_DATA_NEEDED_HEADROOM 16 |
| 21 | #define RMNET_DATA_TX_QUEUE_LEN 1000 |
| 22 | #define RMNET_ETHERNET_HEADER_LENGTH 14 |
| 23 | |
| 24 | extern unsigned int rmnet_data_log_level; |
| 25 | extern unsigned int rmnet_data_log_module_mask; |
| 26 | |
| 27 | #define RMNET_INIT_OK 0 |
| 28 | #define RMNET_INIT_ERROR 1 |
| 29 | |
| 30 | #define RMNET_LOG_LVL_DBG BIT(4) |
| 31 | #define RMNET_LOG_LVL_LOW BIT(3) |
| 32 | #define RMNET_LOG_LVL_MED BIT(2) |
| 33 | #define RMNET_LOG_LVL_HI BIT(1) |
| 34 | #define RMNET_LOG_LVL_ERR BIT(0) |
| 35 | |
| 36 | #define RMNET_LOG_MODULE(X) \ |
| 37 | static u32 rmnet_mod_mask = X |
| 38 | |
| 39 | #define RMNET_DATA_LOGMASK_CONFIG BIT(0) |
| 40 | #define RMNET_DATA_LOGMASK_HANDLER BIT(1) |
| 41 | #define RMNET_DATA_LOGMASK_VND BIT(2) |
| 42 | #define RMNET_DATA_LOGMASK_MAPD BIT(3) |
| 43 | #define RMNET_DATA_LOGMASK_MAPC BIT(4) |
| 44 | |
| 45 | #define LOGE(fmt, ...) do { if (rmnet_data_log_level & RMNET_LOG_LVL_ERR) \ |
| 46 | pr_err("[RMNET:ERR] %s(): " fmt "\n", __func__, \ |
| 47 | ##__VA_ARGS__); \ |
| 48 | } while (0) |
| 49 | |
| 50 | #define LOGH(fmt, ...) do { if (rmnet_data_log_level & RMNET_LOG_LVL_HI) \ |
| 51 | pr_err("[RMNET:HI] %s(): " fmt "\n", __func__, \ |
| 52 | ##__VA_ARGS__); \ |
| 53 | } while (0) |
| 54 | |
| 55 | #define LOGM(fmt, ...) do { if (rmnet_data_log_level & RMNET_LOG_LVL_MED) \ |
| 56 | pr_warn("[RMNET:MED] %s(): " fmt "\n", __func__, \ |
| 57 | ##__VA_ARGS__); \ |
| 58 | } while (0) |
| 59 | |
| 60 | #define LOGL(fmt, ...) do { if (unlikely \ |
| 61 | (rmnet_data_log_level & RMNET_LOG_LVL_LOW)) \ |
| 62 | pr_notice("[RMNET:LOW] %s(): " fmt "\n", __func__, \ |
| 63 | ##__VA_ARGS__); \ |
| 64 | } while (0) |
| 65 | |
| 66 | /* Don't use pr_debug as it is compiled out of the kernel. We can be sure of |
| 67 | * minimal impact as LOGD is not enabled by default. |
| 68 | */ |
| 69 | #define LOGD(fmt, ...) do { if (unlikely( \ |
| 70 | (rmnet_data_log_level & RMNET_LOG_LVL_DBG) && \ |
| 71 | (rmnet_data_log_module_mask & rmnet_mod_mask))) \ |
| 72 | pr_notice("[RMNET:DBG] %s(): " fmt "\n", __func__, \ |
| 73 | ##__VA_ARGS__); \ |
| 74 | } while (0) |
| 75 | |
| 76 | #endif /* _RMNET_DATA_PRIVATE_H_ */ |