qcacmn: use hif_select_service_to_pipe_map for consistency

Copy pasted logic was not maintained, leading to different
maps being used in different code sections. Also fixes
fw assert where multiple wmi services are not available on
the fw for napier.

Change-Id: Iff3ec8938cc16afe0ebae54244060afb0a7d0b2e
CRs-Fixed: 2030840
diff --git a/hif/src/ce/ce_main.c b/hif/src/ce/ce_main.c
index a794ccf..b1b60b7 100644
--- a/hif/src/ce/ce_main.c
+++ b/hif/src/ce/ce_main.c
@@ -418,7 +418,6 @@
 	{ HTC_CTRL_RSVD_SVC, PIPEDIR_IN , 2, },
 	{ HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, },
 	{ HTT_DATA_MSG_SVC, PIPEDIR_IN , 1, },
-	{ PACKET_LOG_SVC, PIPEDIR_IN , 5, },
 	/* (Additions here) */
 	{ 0, 0, 0, },
 };
@@ -523,10 +522,6 @@
 };
 
 
-static struct service_to_pipe *target_service_to_ce_map =
-	target_service_to_ce_map_wlan;
-static int target_service_to_ce_map_sz = sizeof(target_service_to_ce_map_wlan);
-
 static struct shadow_reg_cfg *target_shadow_reg_cfg = target_shadow_reg_cfg_map;
 static int shadow_cfg_sz = sizeof(target_shadow_reg_cfg_map);
 
@@ -550,6 +545,43 @@
 	{0, 0, 0,},             /* Must be last */
 };
 
+static void hif_select_service_to_pipe_map(struct hif_softc *scn,
+				    struct service_to_pipe **tgt_svc_map_to_use,
+				    uint32_t *sz_tgt_svc_map_to_use)
+{
+	uint32_t mode = hif_get_conparam(scn);
+	struct hif_target_info *tgt_info = &scn->target_info;
+
+	if (QDF_IS_EPPING_ENABLED(mode)) {
+		*tgt_svc_map_to_use = target_service_to_ce_map_wlan_epping;
+		*sz_tgt_svc_map_to_use =
+			sizeof(target_service_to_ce_map_wlan_epping);
+	} else {
+		switch (tgt_info->target_type) {
+		default:
+			*tgt_svc_map_to_use = target_service_to_ce_map_wlan;
+			*sz_tgt_svc_map_to_use =
+				sizeof(target_service_to_ce_map_wlan);
+			break;
+		case TARGET_TYPE_AR900B:
+		case TARGET_TYPE_QCA9984:
+		case TARGET_TYPE_IPQ4019:
+		case TARGET_TYPE_QCA9888:
+		case TARGET_TYPE_AR9888:
+		case TARGET_TYPE_AR9888V2:
+			*tgt_svc_map_to_use = target_service_to_ce_map_ar900b;
+			*sz_tgt_svc_map_to_use =
+				sizeof(target_service_to_ce_map_ar900b);
+			break;
+		case TARGET_TYPE_QCA6290:
+			*tgt_svc_map_to_use = target_service_to_ce_map_qca6290;
+			*sz_tgt_svc_map_to_use =
+				sizeof(target_service_to_ce_map_qca6290);
+			break;
+		}
+	}
+}
+
 /**
  * ce_mark_datapath() - marks the ce_state->htt_rx_data accordingly
  * @ce_state : pointer to the state context of the CE
@@ -565,39 +597,14 @@
 static bool ce_mark_datapath(struct CE_state *ce_state)
 {
 	struct service_to_pipe *svc_map;
-	size_t map_sz;
+	uint32_t map_sz;
 	int    i;
 	bool   rc = false;
-	struct hif_target_info *tgt_info;
 
 	if (ce_state != NULL) {
-		tgt_info = &ce_state->scn->target_info;
+		hif_select_service_to_pipe_map(ce_state->scn, &svc_map,
+					       &map_sz);
 
-		if (QDF_IS_EPPING_ENABLED(hif_get_conparam(ce_state->scn))) {
-			svc_map = target_service_to_ce_map_wlan_epping;
-			map_sz = sizeof(target_service_to_ce_map_wlan_epping) /
-				sizeof(struct service_to_pipe);
-		} else {
-			switch (tgt_info->target_type) {
-			default:
-				svc_map = target_service_to_ce_map_wlan;
-				map_sz =
-					sizeof(target_service_to_ce_map_wlan) /
-					sizeof(struct service_to_pipe);
-				break;
-			case TARGET_TYPE_AR900B:
-			case TARGET_TYPE_QCA9984:
-			case TARGET_TYPE_IPQ4019:
-			case TARGET_TYPE_QCA9888:
-			case TARGET_TYPE_AR9888:
-			case TARGET_TYPE_AR9888V2:
-				svc_map = target_service_to_ce_map_ar900b;
-				map_sz =
-					sizeof(target_service_to_ce_map_ar900b)
-					/ sizeof(struct service_to_pipe);
-				break;
-			}
-		}
 		for (i = 0; i < map_sz; i++) {
 			if ((svc_map[i].pipenum == ce_state->id) &&
 			    ((svc_map[i].service_id == HTT_DATA_MSG_SVC)  ||
@@ -2111,6 +2118,7 @@
 	hif_state->started = false;
 }
 
+
 /**
  * hif_get_target_ce_config() - get copy engine configuration
  * @target_ce_config_ret: basic copy engine configuration
@@ -2129,18 +2137,19 @@
  */
 void hif_get_target_ce_config(struct hif_softc *scn,
 		struct CE_pipe_config **target_ce_config_ret,
-		int *target_ce_config_sz_ret,
+		uint32_t *target_ce_config_sz_ret,
 		struct service_to_pipe **target_service_to_ce_map_ret,
-		int *target_service_to_ce_map_sz_ret,
+		uint32_t *target_service_to_ce_map_sz_ret,
 		struct shadow_reg_cfg **target_shadow_reg_cfg_ret,
-		int *shadow_cfg_sz_ret)
+		uint32_t *shadow_cfg_sz_ret)
 {
 	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 
 	*target_ce_config_ret = hif_state->target_ce_config;
 	*target_ce_config_sz_ret = hif_state->target_ce_config_sz;
-	*target_service_to_ce_map_ret = target_service_to_ce_map;
-	*target_service_to_ce_map_sz_ret = target_service_to_ce_map_sz;
+
+	hif_select_service_to_pipe_map(scn, target_service_to_ce_map_ret,
+				       target_service_to_ce_map_sz_ret);
 
 	if (target_shadow_reg_cfg_ret)
 		*target_shadow_reg_cfg_ret = target_shadow_reg_cfg;
@@ -2244,10 +2253,6 @@
 			hif_state->host_ce_config = host_ce_config_wlan_epping_poll;
 		hif_state->target_ce_config = target_ce_config_wlan_epping;
 		hif_state->target_ce_config_sz = sizeof(target_ce_config_wlan_epping);
-		target_service_to_ce_map =
-		    target_service_to_ce_map_wlan_epping;
-		target_service_to_ce_map_sz =
-			sizeof(target_service_to_ce_map_wlan_epping);
 		target_shadow_reg_cfg = target_shadow_reg_cfg_epping;
 		shadow_cfg_sz = sizeof(target_shadow_reg_cfg_epping);
 	}
@@ -2276,9 +2281,6 @@
 		hif_state->target_ce_config_sz =
 				sizeof(target_ce_config_wlan_ar900b);
 
-		target_service_to_ce_map = target_service_to_ce_map_ar900b;
-		target_service_to_ce_map_sz =
-			sizeof(target_service_to_ce_map_ar900b);
 		break;
 
 	case TARGET_TYPE_AR9888:
@@ -2293,9 +2295,6 @@
 		hif_state->target_ce_config_sz =
 					sizeof(target_ce_config_wlan_ar9888);
 
-		target_service_to_ce_map = target_service_to_ce_map_ar900b;
-		target_service_to_ce_map_sz =
-			sizeof(target_service_to_ce_map_ar900b);
 		break;
 
 	case TARGET_TYPE_QCA8074:
@@ -2319,6 +2318,7 @@
 		hif_state->target_ce_config = target_ce_config_wlan_qca6290;
 		hif_state->target_ce_config_sz =
 					sizeof(target_ce_config_wlan_qca6290);
+
 		scn->ce_count = QCA_6290_CE_COUNT;
 		break;
 	}
@@ -2856,42 +2856,14 @@
 	unsigned int i;
 	struct service_to_pipe element;
 	struct service_to_pipe *tgt_svc_map_to_use;
-	size_t sz_tgt_svc_map_to_use;
+	uint32_t sz_tgt_svc_map_to_use;
 	struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
-	uint32_t mode = hif_get_conparam(scn);
-	struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
+	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 	bool dl_updated = false;
 	bool ul_updated = false;
-	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 
-	if (QDF_IS_EPPING_ENABLED(mode)) {
-		tgt_svc_map_to_use = target_service_to_ce_map_wlan_epping;
-		sz_tgt_svc_map_to_use =
-			sizeof(target_service_to_ce_map_wlan_epping);
-	} else {
-		switch (tgt_info->target_type) {
-		default:
-			tgt_svc_map_to_use = target_service_to_ce_map_wlan;
-			sz_tgt_svc_map_to_use =
-				sizeof(target_service_to_ce_map_wlan);
-			break;
-		case TARGET_TYPE_AR900B:
-		case TARGET_TYPE_QCA9984:
-		case TARGET_TYPE_IPQ4019:
-		case TARGET_TYPE_QCA9888:
-		case TARGET_TYPE_AR9888:
-		case TARGET_TYPE_AR9888V2:
-			tgt_svc_map_to_use = target_service_to_ce_map_ar900b;
-			sz_tgt_svc_map_to_use =
-				sizeof(target_service_to_ce_map_ar900b);
-			break;
-		case TARGET_TYPE_QCA6290:
-			tgt_svc_map_to_use = target_service_to_ce_map_qca6290;
-			sz_tgt_svc_map_to_use =
-				sizeof(target_service_to_ce_map_qca6290);
-			break;
-		}
-	}
+	hif_select_service_to_pipe_map(scn, &tgt_svc_map_to_use,
+				       &sz_tgt_svc_map_to_use);
 
 	*dl_is_polled = 0;  /* polling for received messages not supported */