Browse Source

qcacld-3.0: Add support to save gtk and set hlp data in CM

Host add support to save gtk and set hlp data received in connect
response.

Change-Id: If0124584a75175005d01f7f2dc9c10db051edb0a
CRs-Fixed: 2849139
Abhishek Ambure 4 years ago
parent
commit
68f52c6624

+ 14 - 6
core/hdd/inc/wlan_hdd_assoc.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -407,6 +407,8 @@ void hdd_delete_peer(struct hdd_station_ctx *sta_ctx,
 QDF_STATUS
 hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter,
 			     const tSirMacAddr bssid, uint32_t ch_freq);
+
+#ifndef FEATURE_CM_ENABLE
 /**
  * hdd_save_gtk_params() - Save GTK offload params
  * @adapter: HDD adapter
@@ -417,18 +419,24 @@ hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter,
  */
 void hdd_save_gtk_params(struct hdd_adapter *adapter,
 			 struct csr_roam_info *csr_roam_info, bool is_reassoc);
+#endif
+
 #else
+
+#ifndef FEATURE_CM_ENABLE
+static inline void hdd_save_gtk_params(struct hdd_adapter *adapter,
+				       struct csr_roam_info *csr_roam_info,
+				       bool is_reassoc)
+{
+}
+#endif
+
 static inline QDF_STATUS
 hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter,
 			     const tSirMacAddr bssid, uint32_t ch_freq)
 {
 	return QDF_STATUS_SUCCESS;
 }
-static inline void hdd_save_gtk_params(struct hdd_adapter *adapter,
-				       struct csr_roam_info *csr_roam_info,
-				       bool is_reassoc)
-{
-}
 #endif
 
 /**

+ 23 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -4218,6 +4218,20 @@ int hdd_reset_limit_off_chan(struct hdd_adapter *adapter);
  */
 void hdd_clear_fils_connection_info(struct hdd_adapter *adapter);
 
+#ifdef FEATURE_CM_ENABLE
+/**
+ * hdd_update_hlp_info() - Update HLP packet received in FILS (re)assoc rsp
+ * @dev: net device
+ * @rsp: Pointer to connect response
+ *
+ * This API is used to send the received HLP packet in Assoc rsp(FILS AKM)
+ * to the network layer.
+ *
+ * Return: None
+ */
+void hdd_update_hlp_info(struct net_device *dev,
+			 struct wlan_cm_connect_resp *rsp);
+#else
 /**
  * hdd_update_hlp_info() - Update HLP packet received in FILS (re)assoc rsp
  * @dev: net device
@@ -4230,13 +4244,22 @@ void hdd_clear_fils_connection_info(struct hdd_adapter *adapter);
  */
 void hdd_update_hlp_info(struct net_device *dev,
 			 struct csr_roam_info *roam_info);
+#endif
 #else
 static inline void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
 { }
+#ifdef FEATURE_CM_ENABLE
+static inline
+void hdd_update_hlp_info(struct net_device *dev,
+			 struct wlan_cm_connect_resp *rsp)
+{
+}
+#else
 static inline void hdd_update_hlp_info(struct net_device *dev,
 				       struct csr_roam_info *roam_info)
 {}
 #endif
+#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 static inline void hdd_dev_setup_destructor(struct net_device *dev)

+ 5 - 1
core/hdd/src/wlan_hdd_assoc.c

@@ -2204,6 +2204,7 @@ static inline void hdd_send_roamed_ind(struct net_device *dev,
 #endif
 #endif
 
+#ifndef FEATURE_CM_ENABLE
 #if defined(WLAN_FEATURE_ROAM_OFFLOAD)
 #if defined(WLAN_FEATURE_FILS_SK)
 void hdd_save_gtk_params(struct hdd_adapter *adapter,
@@ -2252,7 +2253,6 @@ void hdd_save_gtk_params(struct hdd_adapter *adapter,
 #endif
 #endif
 
-#ifndef FEATURE_CM_ENABLE
 static void hdd_roam_decr_conn_count(struct hdd_adapter *adapter,
 				     struct hdd_context *hdd_ctx)
 {
@@ -5307,6 +5307,10 @@ struct osif_cm_ops osif_ops = {
 	.connect_complete_cb = hdd_cm_connect_complete,
 	.disconnect_complete_cb = hdd_cm_disconnect_complete,
 	.netif_queue_control_cb = hdd_cm_netif_queue_control,
+#ifdef WLAN_FEATURE_FILS_SK
+	.save_gtk_cb = hdd_cm_save_gtk,
+	.set_hlp_data_cb = hdd_cm_set_hlp_data,
+#endif
 };
 
 QDF_STATUS hdd_cm_register_cb(void)

+ 29 - 1
core/hdd/src/wlan_hdd_cm_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -81,6 +81,34 @@ QDF_STATUS hdd_cm_netif_queue_control(struct wlan_objmgr_vdev *vdev,
 QDF_STATUS hdd_cm_connect_complete(struct wlan_objmgr_vdev *vdev,
 				   struct wlan_cm_connect_resp *rsp,
 				   enum osif_cb_type type);
+
+#ifdef WLAN_FEATURE_FILS_SK
+/**
+ * hdd_cm_save_gtk() - save gtk api
+ * @vdev: Pointer to vdev
+ * @rsp: Pointer to connect rsp
+ *
+ * This function is used to save gtk in legacy mode
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
+			   struct wlan_cm_connect_resp *rsp);
+
+/**
+ * hdd_cm_set_hlp_data() - api to set hlp data for dhcp
+ * @dev: pointer to net device
+ * @vdev: Pointer to vdev
+ * @rsp: Pointer to connect rsp
+ *
+ * This function is used to set hlp data for dhcp in legacy mode
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS hdd_cm_set_hlp_data(struct net_device *dev,
+			       struct wlan_objmgr_vdev *vdev,
+			       struct wlan_cm_connect_resp *rsp);
+#endif
 #endif
 
 #ifdef WLAN_FEATURE_MSCS

+ 33 - 0
core/hdd/src/wlan_hdd_cm_connect.c

@@ -796,4 +796,37 @@ QDF_STATUS hdd_cm_connect_complete(struct wlan_objmgr_vdev *vdev,
 
 	return QDF_STATUS_SUCCESS;
 }
+
+#ifdef WLAN_FEATURE_FILS_SK
+QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
+			   struct wlan_cm_connect_resp *rsp)
+{
+	uint8_t *kek;
+	uint32_t kek_len;
+	uint8_t replay_ctr[SIR_REPLAY_CTR_LEN] = {0};
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct hdd_adapter *adapter = hdd_get_adapter_by_vdev(hdd_ctx,
+						wlan_vdev_get_id(vdev));
+
+	if (!adapter || !rsp) {
+		hdd_err("adapter/connect rsp is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	kek = rsp->connect_ies.fils_ie->kek;
+	kek_len = rsp->connect_ies.fils_ie->kek_len;
+	wlan_hdd_save_gtk_offload_params(adapter, NULL, 0, kek, kek_len,
+					 replay_ctr, true);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS hdd_cm_set_hlp_data(struct net_device *dev,
+			       struct wlan_objmgr_vdev *vdev,
+			       struct wlan_cm_connect_resp *rsp)
+{
+	hdd_update_hlp_info(dev, rsp);
+	return QDF_STATUS_SUCCESS;
+}
+#endif
 #endif

+ 65 - 0
core/hdd/src/wlan_hdd_main.c

@@ -7892,6 +7892,70 @@ static void hdd_populate_fils_params(struct cfg80211_connect_resp_params
 #if defined(CFG80211_CONNECT_DONE) || \
 	(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
 
+#ifdef FEATURE_CM_ENABLE
+void hdd_update_hlp_info(struct net_device *dev,
+			 struct wlan_cm_connect_resp *rsp)
+{
+	struct sk_buff *skb;
+	uint16_t skb_len;
+	struct llc_snap_hdr_t *llc_hdr;
+	QDF_STATUS status;
+	uint8_t *hlp_data;
+	uint16_t hlp_data_len;
+	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
+
+	if (!rsp || !rsp->connect_ies.fils_ie) {
+		hdd_err("Connect resp/fils ie is NULL");
+		return;
+	}
+
+	if (!rsp->connect_ies.fils_ie->hlp_data_len) {
+		hdd_debug("FILS HLP Data NULL, len 0");
+		return;
+	}
+
+	hlp_data = rsp->connect_ies.fils_ie->hlp_data;
+	hlp_data_len = rsp->connect_ies.fils_ie->hlp_data_len;
+
+	/* Calculate skb length */
+	skb_len = (2 * ETH_ALEN) + hlp_data_len;
+	skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false);
+	if (!skb) {
+		hdd_err("HLP packet nbuf alloc fails");
+		return;
+	}
+
+	qdf_mem_copy(skb_put(skb, ETH_ALEN),
+		     rsp->connect_ies.fils_ie->dst_mac.bytes,
+		     QDF_MAC_ADDR_SIZE);
+	qdf_mem_copy(skb_put(skb, ETH_ALEN),
+		     rsp->connect_ies.fils_ie->src_mac.bytes,
+		     QDF_MAC_ADDR_SIZE);
+
+	llc_hdr = (struct llc_snap_hdr_t *)hlp_data;
+	if (IS_SNAP(llc_hdr)) {
+		hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE;
+		hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE;
+	}
+
+	qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len);
+
+	/*
+	 * This HLP packet is formed from HLP info encapsulated
+	 * in assoc response frame which is AEAD encrypted.
+	 * Hence, this checksum validation can be set unnecessary.
+	 * i.e. network layer need not worry about checksum.
+	 */
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+	status = hdd_rx_packet_cbk(adapter, skb);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		hdd_err("Sending HLP packet fails");
+		return;
+	}
+	hdd_debug("send HLP packet to netif successfully");
+}
+#else
 void hdd_update_hlp_info(struct net_device *dev,
 			 struct csr_roam_info *roam_info)
 {
@@ -7955,6 +8019,7 @@ void hdd_update_hlp_info(struct net_device *dev,
 	}
 	hdd_debug("send HLP packet to netif successfully");
 }
+#endif
 
 /**
  * hdd_connect_done() - Wrapper API to call cfg80211_connect_done