Browse Source

qcacld-3.0: Converge on struct dhcp_offload_info_params

The driver currently defines two different data structures to hold
DHCP Server Offload configuration:
- typedef tSirDhcpSrvOffloadInfo
- struct dhcp_offload_info_params

To align with the converged software architecture as well as the Linux
coding style remove the legacy typedef and exclusively use the unified
WMI structure.

Change-Id: Ia2b537a917bbe9e36ba4bc3b289e8c2e9ec630d6
CRs-Fixed: 2399938
Jeff Johnson 6 years ago
parent
commit
8bfc29e8cc

+ 28 - 26
core/hdd/src/wlan_hdd_hostapd.c

@@ -4713,8 +4713,8 @@ int wlan_hdd_restore_channels(struct hdd_context *hdd_ctx,
 static void wlan_hdd_set_dhcp_server_offload(struct hdd_adapter *adapter)
 {
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	tpSirDhcpSrvOffloadInfo pDhcpSrvInfo;
-	uint8_t numEntries = 0;
+	struct dhcp_offload_info_params dhcp_srv_info;
+	uint8_t num_entries = 0;
 	uint8_t srv_ip[IPADDR_NUM_ENTRIES];
 	uint8_t num;
 	uint32_t temp;
@@ -4722,45 +4722,47 @@ static void wlan_hdd_set_dhcp_server_offload(struct hdd_adapter *adapter)
 	mac_handle_t mac_handle;
 	QDF_STATUS status;
 
-	pDhcpSrvInfo = qdf_mem_malloc(sizeof(*pDhcpSrvInfo));
-	if (!pDhcpSrvInfo)
-		return;
-	pDhcpSrvInfo->vdev_id = adapter->vdev_id;
-	pDhcpSrvInfo->dhcpSrvOffloadEnabled = true;
+	dhcp_srv_info.vdev_id = adapter->vdev_id;
+	dhcp_srv_info.dhcp_offload_enabled = true;
 
 	status = ucfg_fwol_get_dhcp_max_num_clients(hdd_ctx->psoc,
 						    &dhcp_max_num_clients);
 	if (QDF_IS_STATUS_ERROR(status))
 		return;
 
-	pDhcpSrvInfo->dhcpClientNum = dhcp_max_num_clients;
+	dhcp_srv_info.dhcp_client_num = dhcp_max_num_clients;
 	hdd_string_to_u8_array(hdd_ctx->config->dhcpServerIP,
-			       srv_ip, &numEntries, IPADDR_NUM_ENTRIES);
-	if (numEntries != IPADDR_NUM_ENTRIES) {
-		hdd_err("Incorrect IP address (%s) assigned for DHCP server!", hdd_ctx->config->dhcpServerIP);
-		goto end;
+			       srv_ip, &num_entries, IPADDR_NUM_ENTRIES);
+	if (num_entries != IPADDR_NUM_ENTRIES) {
+		hdd_err("Incorrect IP address (%s) assigned for DHCP server!",
+			hdd_ctx->config->dhcpServerIP);
+		return;
 	}
+
 	if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
-		hdd_err("Invalid IP address (%s)! It could NOT be multicast IP address!", hdd_ctx->config->dhcpServerIP);
-		goto end;
+		hdd_err("Invalid IP address (%s)! It could NOT be multicast IP address!",
+			hdd_ctx->config->dhcpServerIP);
+		return;
 	}
+
 	if (srv_ip[IPADDR_NUM_ENTRIES - 1] >= 100) {
-		hdd_err("Invalid IP address (%s)! The last field must be less than 100!", hdd_ctx->config->dhcpServerIP);
-		goto end;
+		hdd_err("Invalid IP address (%s)! The last field must be less than 100!",
+			hdd_ctx->config->dhcpServerIP);
+		return;
 	}
-	for (num = 0; num < numEntries; num++) {
+
+	dhcp_srv_info.dhcp_srv_addr = 0;
+	for (num = 0; num < num_entries; num++) {
 		temp = srv_ip[num];
-		pDhcpSrvInfo->dhcpSrvIP |= (temp << (8 * num));
+		dhcp_srv_info.dhcp_srv_addr |= (temp << (8 * num));
 	}
+
 	mac_handle = hdd_ctx->mac_handle;
-	if (QDF_STATUS_SUCCESS !=
-	    sme_set_dhcp_srv_offload(mac_handle, pDhcpSrvInfo)) {
-		hdd_err("sme_setDHCPSrvOffload fail!");
-		goto end;
-	}
-	hdd_debug("enable DHCP Server offload successfully!");
-end:
-	qdf_mem_free(pDhcpSrvInfo);
+	status = sme_set_dhcp_srv_offload(mac_handle, &dhcp_srv_info);
+	if (QDF_IS_STATUS_SUCCESS(status))
+		hdd_debug("enable DHCP Server offload successfully!");
+	else
+		hdd_err("sme_set_dhcp_srv_offload fail!");
 }
 
 /**

+ 0 - 9
core/mac/inc/sir_api.h

@@ -4381,15 +4381,6 @@ typedef struct sAniGetLinkStatus {
 	uint8_t sessionId;
 } tAniGetLinkStatus, *tpAniGetLinkStatus;
 
-#ifdef DHCP_SERVER_OFFLOAD
-typedef struct {
-	uint32_t vdev_id;
-	uint32_t dhcpSrvOffloadEnabled;
-	uint32_t dhcpClientNum;
-	uint32_t dhcpSrvIP;
-} tSirDhcpSrvOffloadInfo, *tpSirDhcpSrvOffloadInfo;
-#endif /* DHCP_SERVER_OFFLOAD */
-
 /**
  * struct sir_lost_link_info - lost link information structure.
  *

+ 10 - 2
core/sme/inc/sme_api.h

@@ -1290,8 +1290,16 @@ QDF_STATUS sme_set_scanning_mac_oui(mac_handle_t mac_handle,
 				    struct scan_mac_oui *scan_mac_oui);
 
 #ifdef DHCP_SERVER_OFFLOAD
-QDF_STATUS sme_set_dhcp_srv_offload(mac_handle_t mac_handle,
-		tSirDhcpSrvOffloadInfo * pDhcpSrvInfo);
+/**
+ * sme_set_dhcp_srv_offload() - Set DHCP server offload
+ * @mac_handle: Handle to the global MAC context
+ * @dhcp_srv_info : DHCP server offload info struct
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+sme_set_dhcp_srv_offload(mac_handle_t mac_handle,
+			 struct dhcp_offload_info_params *dhcp_srv_info);
 #endif /* DHCP_SERVER_OFFLOAD */
 #ifdef WLAN_FEATURE_GPIO_LED_FLASHING
 QDF_STATUS sme_set_led_flashing(mac_handle_t mac_handle, uint8_t type,

+ 10 - 17
core/sme/src/common/sme_api.c

@@ -10466,33 +10466,26 @@ QDF_STATUS sme_set_scanning_mac_oui(mac_handle_t mac_handle,
 }
 
 #ifdef DHCP_SERVER_OFFLOAD
-/*
- * sme_set_dhcp_srv_offload() -
- * SME API to set DHCP server offload info
- *
- * mac_handle
- * pDhcpSrvInfo : DHCP server offload info struct
- * Return QDF_STATUS
- */
-QDF_STATUS sme_set_dhcp_srv_offload(mac_handle_t mac_handle,
-				    tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
+QDF_STATUS
+sme_set_dhcp_srv_offload(mac_handle_t mac_handle,
+			 struct dhcp_offload_info_params *dhcp_srv_info)
 {
 	struct scheduler_msg message = {0};
-	tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
+	struct dhcp_offload_info_params *payload;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	struct mac_context *mac = MAC_CONTEXT(mac_handle);
 
-	pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
-	if (!pSmeDhcpSrvInfo)
+	payload = qdf_mem_malloc(sizeof(*payload));
+	if (!payload)
 		return QDF_STATUS_E_NOMEM;
 
-	*pSmeDhcpSrvInfo = *pDhcpSrvInfo;
+	*payload = *dhcp_srv_info;
 
 	status = sme_acquire_global_lock(&mac->sme);
 	if (QDF_STATUS_SUCCESS == status) {
 		/* serialize the req through MC thread */
 		message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
-		message.bodyptr = pSmeDhcpSrvInfo;
+		message.bodyptr = payload;
 
 		if (!QDF_IS_STATUS_SUCCESS
 			    (scheduler_post_message(QDF_MODULE_ID_SME,
@@ -10502,14 +10495,14 @@ QDF_STATUS sme_set_dhcp_srv_offload(mac_handle_t mac_handle,
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
 				  "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
 				  __func__);
-			qdf_mem_free(pSmeDhcpSrvInfo);
+			qdf_mem_free(payload);
 			status = QDF_STATUS_E_FAILURE;
 		}
 		sme_release_global_lock(&mac->sme);
 	} else {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
 			  "%s: sme_acquire_global_lock error!", __func__);
-		qdf_mem_free(pSmeDhcpSrvInfo);
+		qdf_mem_free(payload);
 	}
 
 	return status;

+ 10 - 3
core/wma/inc/wma_internal.h

@@ -1231,9 +1231,16 @@ static inline QDF_STATUS wma_set_tsf_gpio_pin(WMA_HANDLE handle, uint32_t pin)
 QDF_STATUS wma_set_wisa_params(tp_wma_handle wma, struct sir_wisa_params *wisa);
 
 #ifdef DHCP_SERVER_OFFLOAD
-QDF_STATUS wma_process_dhcpserver_offload(tp_wma_handle wma_handle,
-					  tSirDhcpSrvOffloadInfo *
-					  pDhcpSrvOffloadInfo);
+/**
+ * wma_process_dhcpserver_offload() - enable DHCP server offload
+ * @wma_handle: wma handle
+ * @params: DHCP server offload information
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+QDF_STATUS
+wma_process_dhcpserver_offload(tp_wma_handle wma_handle,
+			       struct dhcp_offload_info_params *params);
 #endif
 
 #ifdef WLAN_FEATURE_GPIO_LED_FLASHING

+ 9 - 23
core/wma/src/wma_features.c

@@ -3852,38 +3852,24 @@ QDF_STATUS wma_set_auto_shutdown_timer_req(tp_wma_handle wma_handle,
 #endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
 
 #ifdef DHCP_SERVER_OFFLOAD
-/**
- * wma_process_dhcpserver_offload() - enable DHCP server offload
- * @wma_handle: wma handle
- * @pDhcpSrvOffloadInfo: DHCP server offload info
- *
- * Return: 0 for success or error code
- */
-QDF_STATUS wma_process_dhcpserver_offload(tp_wma_handle wma_handle,
-					  tSirDhcpSrvOffloadInfo *
-					  pDhcpSrvOffloadInfo)
+QDF_STATUS
+wma_process_dhcpserver_offload(tp_wma_handle wma_handle,
+			       struct dhcp_offload_info_params *params)
 {
-	struct dhcp_offload_info_params params = {0};
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!wma_handle) {
 		WMA_LOGE("%s: wma handle is NULL", __func__);
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	params.vdev_id = pDhcpSrvOffloadInfo->vdev_id;
-	params.dhcp_offload_enabled =
-				pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
-	params.dhcp_client_num = pDhcpSrvOffloadInfo->dhcpClientNum;
-	params.dhcp_srv_addr = pDhcpSrvOffloadInfo->dhcpSrvIP;
-
-	status = wmi_unified_process_dhcpserver_offload_cmd(
-				wma_handle->wmi_handle, &params);
-	if (QDF_IS_STATUS_ERROR(status))
-		return status;
+	wmi_handle = wma_handle->wmi_handle;
+	status = wmi_unified_process_dhcpserver_offload_cmd(wmi_handle,
+							    params);
+	WMA_LOGD("Set dhcp server offload to vdev %d status %d",
+		 params->vdev_id, status);
 
-	WMA_LOGD("Set dhcp server offload to vdevId %d",
-		 pDhcpSrvOffloadInfo->vdev_id);
 	return status;
 }
 #endif /* DHCP_SERVER_OFFLOAD */