Browse Source

qcacmn: Swap bytes of key_data in big endian platform

Swap each word of key_data before sending key install command.
This is needed since copy engine swap is enabled for big endian platform
and key needs to be plumbed in network byte order for decoding to happen
correctly.

Handle the swap in wmi layer since all other big endian conversions are
handled in this layer.

Change-Id: Ia6f0d579f3edaf32193c353ea2fe35cc40f55399
Nandha Kishore Easwaran 4 years ago
parent
commit
6547f0f671
2 changed files with 10 additions and 25 deletions
  1. 1 23
      target_if/crypto/src/target_if_crypto.c
  2. 9 2
      wmi/src/wmi_unified_tlv.c

+ 1 - 23
target_if/crypto/src/target_if_crypto.c

@@ -127,26 +127,6 @@ static inline void wlan_crypto_set_wapi_key(struct wlan_objmgr_vdev *vdev,
 }
 }
 #endif /* FEATURE_WLAN_WAPI */
 #endif /* FEATURE_WLAN_WAPI */
 
 
-#ifdef BIG_ENDIAN_HOST
-static void wlan_crypto_endianness_conversion(uint8_t *dest, uint8_t *src,
-					      uint32_t keylen)
-{
-	int8_t i;
-
-	for (i = 0; i < roundup(keylen, sizeof(uint32_t)) / 4; i++) {
-		*dest = le32_to_cpu(*src);
-		dest++;
-		src++;
-	}
-}
-#else
-static void wlan_crypto_endianness_conversion(uint8_t *dest, uint8_t *src,
-					      uint32_t keylen)
-{
-	qdf_mem_copy(dest, src, keylen);
-}
-#endif
-
 QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
 QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
 				    struct wlan_crypto_key *req,
 				    struct wlan_crypto_key *req,
 				    enum wlan_crypto_key_type key_type)
 				    enum wlan_crypto_key_type key_type)
@@ -234,9 +214,7 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
 		break;
 		break;
 	}
 	}
 
 
-	wlan_crypto_endianness_conversion(&params.key_data[0],
-					  &req->keyval[0],
-					  req->keylen);
+	qdf_mem_copy(&params.key_data[0], &req->keyval[0], req->keylen);
 	params.key_len = req->keylen;
 	params.key_len = req->keylen;
 
 
 	/* Set PN check & security type in data path */
 	/* Set PN check & security type in data path */

+ 9 - 2
wmi/src/wmi_unified_tlv.c

@@ -4461,8 +4461,15 @@ static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
 		       roundup(key_params->key_len, sizeof(uint32_t)));
 		       roundup(key_params->key_len, sizeof(uint32_t)));
 	key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
 	key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
-	qdf_mem_copy((void *)key_data,
-		     (const void *)key_params->key_data, key_params->key_len);
+
+	/* for big endian host, copy engine byte_swap is enabled
+	 * But key_data is in network byte order
+	 * Need to byte swap the key_data - so when copy engine
+	 * does byte_swap - target gets key_data in the correct order
+	 */
+	WMI_HOST_IF_MSG_COPY_CHAR_ARRAY((void *)key_data,
+					(const void *)key_params->key_data,
+					key_params->key_len);
 	qdf_mem_copy(&cmd->key_rsc_counter, &key_params->key_rsc_ctr,
 	qdf_mem_copy(&cmd->key_rsc_counter, &key_params->key_rsc_ctr,
 		     sizeof(wmi_key_seq_counter));
 		     sizeof(wmi_key_seq_counter));
 	cmd->key_len = key_params->key_len;
 	cmd->key_len = key_params->key_len;