diff options
author | Michal Kazior <michal.kazior@tieto.com> | 2014-09-18 09:21:22 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@qca.qualcomm.com> | 2014-09-23 05:31:07 -0400 |
commit | cf9fca8f890e04a745fc9997ed75bcf0ed13b12b (patch) | |
tree | 57b5c30d90f33f9393c3cecf452d67b3ff95d659 /drivers/net/wireless/ath/ath10k/wmi.c | |
parent | 2d66721c7bb1a6888eb17dd29758daf642df0b82 (diff) |
ath10k: deduplicate host mem chunk code
Simplify the code by deduplicating structure
definitions and code.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/wmi.c')
-rw-r--r-- | drivers/net/wireless/ath/ath10k/wmi.c | 103 |
1 files changed, 25 insertions, 78 deletions
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 34c214b73f99..e796305ad5e1 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c | |||
@@ -2963,13 +2963,34 @@ int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value) | |||
2963 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid); | 2963 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid); |
2964 | } | 2964 | } |
2965 | 2965 | ||
2966 | static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar, | ||
2967 | struct wmi_host_mem_chunks *chunks) | ||
2968 | { | ||
2969 | struct host_memory_chunk *chunk; | ||
2970 | int i; | ||
2971 | |||
2972 | chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks); | ||
2973 | |||
2974 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { | ||
2975 | chunk = &chunks->items[i]; | ||
2976 | chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); | ||
2977 | chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len); | ||
2978 | chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); | ||
2979 | |||
2980 | ath10k_dbg(ar, ATH10K_DBG_WMI, | ||
2981 | "wmi chunk %d len %d requested, addr 0x%llx\n", | ||
2982 | i, | ||
2983 | ar->wmi.mem_chunks[i].len, | ||
2984 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); | ||
2985 | } | ||
2986 | } | ||
2987 | |||
2966 | static int ath10k_wmi_main_cmd_init(struct ath10k *ar) | 2988 | static int ath10k_wmi_main_cmd_init(struct ath10k *ar) |
2967 | { | 2989 | { |
2968 | struct wmi_init_cmd *cmd; | 2990 | struct wmi_init_cmd *cmd; |
2969 | struct sk_buff *buf; | 2991 | struct sk_buff *buf; |
2970 | struct wmi_resource_config config = {}; | 2992 | struct wmi_resource_config config = {}; |
2971 | u32 len, val; | 2993 | u32 len, val; |
2972 | int i; | ||
2973 | 2994 | ||
2974 | config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS); | 2995 | config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS); |
2975 | config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS); | 2996 | config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS); |
@@ -3031,32 +3052,8 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar) | |||
3031 | 3052 | ||
3032 | cmd = (struct wmi_init_cmd *)buf->data; | 3053 | cmd = (struct wmi_init_cmd *)buf->data; |
3033 | 3054 | ||
3034 | if (ar->wmi.num_mem_chunks == 0) { | ||
3035 | cmd->num_host_mem_chunks = 0; | ||
3036 | goto out; | ||
3037 | } | ||
3038 | |||
3039 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n", | ||
3040 | ar->wmi.num_mem_chunks); | ||
3041 | |||
3042 | cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); | ||
3043 | |||
3044 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { | ||
3045 | cmd->host_mem_chunks[i].ptr = | ||
3046 | __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); | ||
3047 | cmd->host_mem_chunks[i].size = | ||
3048 | __cpu_to_le32(ar->wmi.mem_chunks[i].len); | ||
3049 | cmd->host_mem_chunks[i].req_id = | ||
3050 | __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); | ||
3051 | |||
3052 | ath10k_dbg(ar, ATH10K_DBG_WMI, | ||
3053 | "wmi chunk %d len %d requested, addr 0x%llx\n", | ||
3054 | i, | ||
3055 | ar->wmi.mem_chunks[i].len, | ||
3056 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); | ||
3057 | } | ||
3058 | out: | ||
3059 | memcpy(&cmd->resource_config, &config, sizeof(config)); | 3055 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
3056 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); | ||
3060 | 3057 | ||
3061 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n"); | 3058 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n"); |
3062 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); | 3059 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
@@ -3068,7 +3065,6 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) | |||
3068 | struct sk_buff *buf; | 3065 | struct sk_buff *buf; |
3069 | struct wmi_resource_config_10x config = {}; | 3066 | struct wmi_resource_config_10x config = {}; |
3070 | u32 len, val; | 3067 | u32 len, val; |
3071 | int i; | ||
3072 | 3068 | ||
3073 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); | 3069 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
3074 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); | 3070 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
@@ -3122,32 +3118,8 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) | |||
3122 | 3118 | ||
3123 | cmd = (struct wmi_init_cmd_10x *)buf->data; | 3119 | cmd = (struct wmi_init_cmd_10x *)buf->data; |
3124 | 3120 | ||
3125 | if (ar->wmi.num_mem_chunks == 0) { | ||
3126 | cmd->num_host_mem_chunks = 0; | ||
3127 | goto out; | ||
3128 | } | ||
3129 | |||
3130 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n", | ||
3131 | ar->wmi.num_mem_chunks); | ||
3132 | |||
3133 | cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); | ||
3134 | |||
3135 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { | ||
3136 | cmd->host_mem_chunks[i].ptr = | ||
3137 | __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); | ||
3138 | cmd->host_mem_chunks[i].size = | ||
3139 | __cpu_to_le32(ar->wmi.mem_chunks[i].len); | ||
3140 | cmd->host_mem_chunks[i].req_id = | ||
3141 | __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); | ||
3142 | |||
3143 | ath10k_dbg(ar, ATH10K_DBG_WMI, | ||
3144 | "wmi chunk %d len %d requested, addr 0x%llx\n", | ||
3145 | i, | ||
3146 | ar->wmi.mem_chunks[i].len, | ||
3147 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); | ||
3148 | } | ||
3149 | out: | ||
3150 | memcpy(&cmd->resource_config, &config, sizeof(config)); | 3121 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
3122 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); | ||
3151 | 3123 | ||
3152 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n"); | 3124 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n"); |
3153 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); | 3125 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
@@ -3159,7 +3131,6 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar) | |||
3159 | struct sk_buff *buf; | 3131 | struct sk_buff *buf; |
3160 | struct wmi_resource_config_10x config = {}; | 3132 | struct wmi_resource_config_10x config = {}; |
3161 | u32 len, val; | 3133 | u32 len, val; |
3162 | int i; | ||
3163 | 3134 | ||
3164 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); | 3135 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
3165 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); | 3136 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
@@ -3213,32 +3184,8 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar) | |||
3213 | 3184 | ||
3214 | cmd = (struct wmi_init_cmd_10_2 *)buf->data; | 3185 | cmd = (struct wmi_init_cmd_10_2 *)buf->data; |
3215 | 3186 | ||
3216 | if (ar->wmi.num_mem_chunks == 0) { | ||
3217 | cmd->num_host_mem_chunks = 0; | ||
3218 | goto out; | ||
3219 | } | ||
3220 | |||
3221 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n", | ||
3222 | ar->wmi.num_mem_chunks); | ||
3223 | |||
3224 | cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks); | ||
3225 | |||
3226 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { | ||
3227 | cmd->host_mem_chunks[i].ptr = | ||
3228 | __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); | ||
3229 | cmd->host_mem_chunks[i].size = | ||
3230 | __cpu_to_le32(ar->wmi.mem_chunks[i].len); | ||
3231 | cmd->host_mem_chunks[i].req_id = | ||
3232 | __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); | ||
3233 | |||
3234 | ath10k_dbg(ar, ATH10K_DBG_WMI, | ||
3235 | "wmi chunk %d len %d requested, addr 0x%llx\n", | ||
3236 | i, | ||
3237 | ar->wmi.mem_chunks[i].len, | ||
3238 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); | ||
3239 | } | ||
3240 | out: | ||
3241 | memcpy(&cmd->resource_config.common, &config, sizeof(config)); | 3187 | memcpy(&cmd->resource_config.common, &config, sizeof(config)); |
3188 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); | ||
3242 | 3189 | ||
3243 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n"); | 3190 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n"); |
3244 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); | 3191 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |