|
@@ -22,3 +22,76 @@
|
|
|
#include "wlan_mgmt_txrx_rx_reo_i.h"
|
|
|
|
|
|
struct mgmt_rx_reo_context rx_reo_global;
|
|
|
+
|
|
|
+#define MGMT_RX_REO_PKT_CTR_HALF_RANGE (0x8000)
|
|
|
+#define MGMT_RX_REO_PKT_CTR_FULL_RANGE (MGMT_RX_REO_PKT_CTR_HALF_RANGE << 1)
|
|
|
+
|
|
|
+/**
|
|
|
+ * mgmt_rx_reo_compare_pkt_ctrs_gte() - Compare given mgmt packet counters
|
|
|
+ * @ctr1: Management packet counter1
|
|
|
+ * @ctr2: Management packet counter2
|
|
|
+ *
|
|
|
+ * We can't directly use the comparison operator here because the counters can
|
|
|
+ * overflow. But these counters have a property that the difference between
|
|
|
+ * them can never be greater than half the range of the data type.
|
|
|
+ * We can make use of this condition to detect which one is actually greater.
|
|
|
+ *
|
|
|
+ * Return: true if @ctr1 is greater than or equal to @ctr2, else false
|
|
|
+ */
|
|
|
+static inline bool
|
|
|
+mgmt_rx_reo_compare_pkt_ctrs_gte(uint16_t ctr1, uint16_t ctr2)
|
|
|
+{
|
|
|
+ uint16_t delta = ctr1 - ctr2;
|
|
|
+
|
|
|
+ return delta <= MGMT_RX_REO_PKT_CTR_HALF_RANGE;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * mgmt_rx_reo_subtract_pkt_ctrs() - Subtract given mgmt packet counters
|
|
|
+ * @ctr1: Management packet counter1
|
|
|
+ * @ctr2: Management packet counter2
|
|
|
+ *
|
|
|
+ * We can't directly use the subtract operator here because the counters can
|
|
|
+ * overflow. But these counters have a property that the difference between
|
|
|
+ * them can never be greater than half the range of the data type.
|
|
|
+ * We can make use of this condition to detect whichone is actually greater and
|
|
|
+ * return the difference accordingly.
|
|
|
+ *
|
|
|
+ * Return: Difference between @ctr1 and @crt2
|
|
|
+ */
|
|
|
+static inline int
|
|
|
+mgmt_rx_reo_subtract_pkt_ctrs(uint16_t ctr1, uint16_t ctr2)
|
|
|
+{
|
|
|
+ uint16_t delta = ctr1 - ctr2;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * if delta is greater than half the range (i.e, ctr1 is actually
|
|
|
+ * smaller than ctr2), then the result should be a negative number.
|
|
|
+ * subtracting the entire range should give the correct value.
|
|
|
+ */
|
|
|
+ if (delta > MGMT_RX_REO_PKT_CTR_HALF_RANGE)
|
|
|
+ return delta - MGMT_RX_REO_PKT_CTR_FULL_RANGE;
|
|
|
+
|
|
|
+ return delta;
|
|
|
+}
|
|
|
+
|
|
|
+#define MGMT_RX_REO_GLOBAL_TS_HALF_RANGE (0x80000000)
|
|
|
+/**
|
|
|
+ * mgmt_rx_reo_compare_global_timestamps_gte()-Compare given global timestamps
|
|
|
+ * @ts1: Global timestamp1
|
|
|
+ * @ts2: Global timestamp2
|
|
|
+ *
|
|
|
+ * We can't directly use the comparison operator here because the timestamps can
|
|
|
+ * overflow. But these timestamps have a property that the difference between
|
|
|
+ * them can never be greater than half the range of the data type.
|
|
|
+ * We can make use of this condition to detect which one is actually greater.
|
|
|
+ *
|
|
|
+ * Return: true if @ts1 is greater than or equal to @ts2, else false
|
|
|
+ */
|
|
|
+static inline bool
|
|
|
+mgmt_rx_reo_compare_global_timestamps_gte(uint32_t ts1, uint32_t ts2)
|
|
|
+{
|
|
|
+ uint32_t delta = ts1 - ts2;
|
|
|
+
|
|
|
+ return delta <= MGMT_RX_REO_GLOBAL_TS_HALF_RANGE;
|
|
|
+}
|