فهرست منبع

qcacmn: Add API to find Multi-Link element based on variant

Based on the ML IE variant, add new API to find the first
Multi-Link element or the start of the first Multi-Link
element fragment sequence in a given buffer containing
elements, if a Multi-Link element or element fragment
sequence exists in the given buffer.

Change-Id: I89535f67aeb012c872216c8971b29f5afa359d07
CRs-Fixed: 3326673
Deeksha Gupta 2 سال پیش
والد
کامیت
730d9abd4d
2فایلهای تغییر یافته به همراه106 افزوده شده و 2 حذف شده
  1. 49 2
      umac/mlo_mgr/inc/utils_mlo.h
  2. 57 0
      umac/mlo_mgr/src/utils_mlo.c

+ 49 - 2
umac/mlo_mgr/inc/utils_mlo.h

@@ -161,6 +161,46 @@ QDF_STATUS
 util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
 util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
 	       qdf_size_t *mlieseqlen);
 	       qdf_size_t *mlieseqlen);
 
 
+/**
+ * util_find_mlie_by_variant - Find the first Multi-Link element or the start of
+ * the first Multi-Link element fragment sequence in a given buffer containing
+ * elements based on variant, if a Multi-Link element or element fragment
+ * sequence exists in the given buffer.
+ *
+ * @buf: Buffer to be searched for the Multi-Link element or the start of the
+ * Multi-Link element fragment sequence
+ * @buflen: Length of the buffer
+ * @mlieseq: Based on the variant, pointer to location where the starting
+ * address of the Multi-Link element or Multi-Link element fragment sequence
+ * should be updated if found in the given buffer. The value NULL will be
+ * updated to this location if the element or element fragment sequence is not
+ * found. This should be ignored by the caller if the function returns error.
+ * @mlieseqlen: Pointer to location where the total length of the Multi-Link
+ * element or Multi-Link element fragment sequence should be updated if found
+ * in the given buffer. This should be ignored by the caller if the function
+ * returns error, or if the function indicates that the element or element
+ * fragment sequence was not found by providing a starting address of NULL.
+ * @variant: Multi-Link element variant.  The value should be interpreted by the
+ * caller as a member of enum wlan_ml_variant. (This enum is not directly used
+ * as an argument, so that non-MLO code that happens to call this function does
+ * not need to be aware of the definition of the enum, though such a call would
+ * ultimately result in an error).
+ *
+ * Based on variant, find the Multi-Link element or the start of the Multi-Link
+ * element fragment sequence in a given buffer containing elements, if a
+ * Multi-Link element or element fragment sequence exists in the given buffer.
+ * The buffer should contain only 802.11 Information elements, and thus should
+ * not contain other information like 802.11 header, 802.11 frame body
+ * components like fields that are not elements (e.g. Capability Information
+ * field, Beacon Interval field), etc.
+ *
+ * Return: QDF_STATUS_SUCCESS in the case of success, QDF_STATUS value giving
+ * the reason for error in the case of failure
+ */
+QDF_STATUS
+util_find_mlie_by_variant(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
+			  qdf_size_t *mlieseqlen, int variant);
+
 /**
 /**
  * util_get_mlie_variant() - Get ML IE variant
  * util_get_mlie_variant() - Get ML IE variant
  * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
  * @mlieseq: Starting address of the Multi-Link element or Multi-Link element
@@ -190,8 +230,8 @@ util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
  * fragment sequence
  * fragment sequence
  * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  * @mlieseqlen: Total length of the Multi-Link element or Multi-Link element
  * fragment sequence
  * fragment sequence
- * @linkid: Pointer to the location where the MLD MAC address should be updated.
- * This should be ignored by the caller if the function returns error.
+ * @mldmacaddr: Pointer to the location where the MLD MAC address should be
+ * updated. This should be ignored by the caller if the function returns error.
  *
  *
  * Get the MLD MAC address from a given Basic variant Multi-Link element
  * Get the MLD MAC address from a given Basic variant Multi-Link element
  * or element fragment sequence.
  * or element fragment sequence.
@@ -452,6 +492,13 @@ util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
 	return QDF_STATUS_E_NOSUPPORT;
 	return QDF_STATUS_E_NOSUPPORT;
 }
 }
 
 
+static inline QDF_STATUS
+util_find_mlie_by_variant(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
+			  qdf_size_t *mlieseqlen)
+{
+	return QDF_STATUS_E_FAILURE;
+}
+
 static inline QDF_STATUS
 static inline QDF_STATUS
 util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
 util_get_mlie_variant(uint8_t *mlieseq, qdf_size_t mlieseqlen,
 		      int *variant)
 		      int *variant)

+ 57 - 0
umac/mlo_mgr/src/utils_mlo.c

@@ -2899,6 +2899,63 @@ util_find_mlie(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
 	return QDF_STATUS_SUCCESS;
 	return QDF_STATUS_SUCCESS;
 }
 }
 
 
+QDF_STATUS
+util_find_mlie_by_variant(uint8_t *buf, qdf_size_t buflen, uint8_t **mlieseq,
+			  qdf_size_t *mlieseqlen, int variant)
+{
+	uint8_t *ieseq;
+	qdf_size_t ieseqlen;
+	QDF_STATUS status;
+	int ml_variant;
+	qdf_size_t buf_parsed_len;
+
+	if (!buf || !buflen || !mlieseq || !mlieseqlen)
+		return QDF_STATUS_E_NULL_VALUE;
+
+	if (variant >= WLAN_ML_VARIANT_INVALIDSTART)
+		return QDF_STATUS_E_PROTO;
+
+	ieseq = NULL;
+	ieseqlen = 0;
+	*mlieseq = NULL;
+	*mlieseqlen = 0;
+	buf_parsed_len = 0;
+
+	while (buflen > buf_parsed_len) {
+		status = util_find_mlie(buf + buf_parsed_len,
+					buflen - buf_parsed_len,
+					&ieseq, &ieseqlen);
+
+		if (QDF_IS_STATUS_ERROR(status))
+			return status;
+
+		/* Even if the element is not found, we have successfully
+		 * examined the buffer. The caller will be provided a NULL value
+		 * for the starting of the Multi-Link element. Hence, we return
+		 * success.
+		 */
+		if (!ieseq)
+			return QDF_STATUS_SUCCESS;
+
+		status = util_get_mlie_variant(ieseq, ieseqlen,
+					       &ml_variant);
+		if (QDF_IS_STATUS_ERROR(status)) {
+			mlo_err("Unable to get Multi-link element variant");
+			return status;
+		}
+
+		if (ml_variant == variant) {
+			*mlieseq = ieseq;
+			*mlieseqlen = ieseqlen;
+			return QDF_STATUS_SUCCESS;
+		}
+
+		buf_parsed_len = ieseq + ieseqlen - buf;
+	}
+
+	return QDF_STATUS_E_INVAL;
+}
+
 QDF_STATUS
 QDF_STATUS
 util_get_mlie_common_info_len(uint8_t *mlieseq, qdf_size_t mlieseqlen,
 util_get_mlie_common_info_len(uint8_t *mlieseq, qdf_size_t mlieseqlen,
 			      uint8_t *commoninfo_len)
 			      uint8_t *commoninfo_len)