|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
|
|
|
+ * Copyright (c) 2011-2019 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
|
|
@@ -148,251 +148,6 @@ static inline uint32_t sir_swap_u32if_needed(uint32_t val)
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-static inline void sir_swap_u32_buf(uint32_t *ptr, uint32_t nWords)
|
|
|
-{
|
|
|
- uint32_t i;
|
|
|
-
|
|
|
- for (i = 0; i < nWords; i++)
|
|
|
- ptr[i] = sir_swap_u32(ptr[i]);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_swap_u32_buf_if_needed()
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * This function is called to swap U8s of U32s in the buffer depending
|
|
|
- * on endiannes of the target processor/compiler the software is
|
|
|
- * running on
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param pBuf Buffer that will get swapped
|
|
|
- * @param nWords Number DWORDS will be swapped
|
|
|
- * @return void
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_swap_u32_buf_if_needed(uint32_t *pBuf, uint32_t nWords)
|
|
|
-{
|
|
|
-#ifdef ANI_LITTLE_BYTE_ENDIAN
|
|
|
- sir_swap_u32_buf(pBuf, nWords);
|
|
|
-#endif
|
|
|
-} /*** end sir_swap_u32if_needed() ***/
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_swap_bd_if_needed
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * Byte swap all the dwords in the BD, except the PHY/MAC headers
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param pBd BD that will get swapped
|
|
|
- * @return void
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_swap_bd_if_needed(uint32_t *pBd)
|
|
|
-{
|
|
|
- sir_swap_u32_buf_if_needed(pBd, 6);
|
|
|
- sir_swap_u32_buf_if_needed(pBd + 18, 14);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_store_u16_n
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It stores a 16 bit number into the byte array in network byte order
|
|
|
- * i.e. the least significant byte first
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of destination byte array
|
|
|
- * @param val value to store
|
|
|
- * @return None
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_store_u16_n(uint8_t *ptr, uint16_t val)
|
|
|
-{
|
|
|
- *ptr++ = (val >> 8) & 0xff;
|
|
|
- *ptr = val & 0xff;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_store_u32_n
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It stores a 32 bit number into the byte array in network byte order
|
|
|
- * i.e. the least significant byte first
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of destination byte array
|
|
|
- * @param val value to store
|
|
|
- * @return None
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_store_u32_n(uint8_t *ptr, uint32_t val)
|
|
|
-{
|
|
|
- *ptr++ = (uint8_t) (val >> 24) & 0xff;
|
|
|
- *ptr++ = (uint8_t) (val >> 16) & 0xff;
|
|
|
- *ptr++ = (uint8_t) (val >> 8) & 0xff;
|
|
|
- *ptr = (uint8_t) (val) & 0xff;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_store_u16
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It stores a 16 bit number into the byte array in NON-network byte order
|
|
|
- * i.e. the least significant byte first
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of destination byte array
|
|
|
- * @param val value to store
|
|
|
- * @return None
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_store_u16(uint8_t *ptr, uint16_t val)
|
|
|
-{
|
|
|
- *ptr++ = val & 0xff;
|
|
|
- *ptr = (val >> 8) & 0xff;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_store_u32
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It stores a 32 bit number into the byte array in NON-network byte order
|
|
|
- * i.e. the least significant byte first
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of destination byte array
|
|
|
- * @param val value to store
|
|
|
- * @return None
|
|
|
- */
|
|
|
-
|
|
|
-static inline void sir_store_u32(uint8_t *ptr, uint32_t val)
|
|
|
-{
|
|
|
- *ptr++ = (uint8_t) val & 0xff;
|
|
|
- *ptr++ = (uint8_t) (val >> 8) & 0xff;
|
|
|
- *ptr++ = (uint8_t) (val >> 16) & 0xff;
|
|
|
- *ptr = (uint8_t) (val >> 24) & 0xff;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_store_u32BufN
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It stores a 32 bit number into the byte array in network byte order
|
|
|
- * i.e. the least significant byte first. It performs the above operation
|
|
|
- * on entire buffer and writes to the dst buffer
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * Assumes that the pSrc buffer is of all uint32_t data type fields.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- * Must be used if all the fields in the buffer must be of uint32_t types.
|
|
|
- *
|
|
|
- * @param pDst address of destination byte array
|
|
|
- * @param pSrc address of the source DWORD array
|
|
|
- * @param length number of DWORDs
|
|
|
- * @return None
|
|
|
- */
|
|
|
-
|
|
|
-static inline void
|
|
|
-sir_store_buf_n(uint8_t *pDst, uint32_t *pSrc, uint32_t length)
|
|
|
-{
|
|
|
- while (length) {
|
|
|
- sir_store_u32_n(pDst, *pSrc);
|
|
|
- pDst += 4;
|
|
|
- pSrc++;
|
|
|
- length--;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_read_u16_n
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It reads a 16 bit number from the byte array in network byte order
|
|
|
- * i.e. the least significant byte first
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of byte array
|
|
|
- * @return 16 bit value
|
|
|
- */
|
|
|
-
|
|
|
-static inline uint16_t sir_read_u16_n(uint8_t *ptr)
|
|
|
-{
|
|
|
- return ((*ptr) << 8) | (*(ptr + 1));
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * sir_swap_u32_buf
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * It swaps N dwords into the same buffer
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * None.
|
|
|
- *
|
|
|
- * NOTE:
|
|
|
- *
|
|
|
- * @param ptr address of uint32_t array
|
|
|
- * @return void
|
|
|
- *
|
|
|
- */
|
|
|
-
|
|
|
-static inline void
|
|
|
-sir_swap_n_store(uint32_t *src, uint32_t *dst, uint32_t nWords)
|
|
|
-{
|
|
|
- uint32_t i;
|
|
|
-
|
|
|
- for (i = 0; i < nWords; i++)
|
|
|
- dst[i] = sir_swap_u32(src[i]);
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* sir_read_u32_n
|
|
|
*
|
|
@@ -552,24 +307,4 @@ static inline uint8_t convert_cw(uint16_t cw)
|
|
|
#define WLAN_UP_TO_AC_MAP 0x33220110
|
|
|
#define upToAc(up) ((WLAN_UP_TO_AC_MAP >> ((up) << 2)) & 0x03)
|
|
|
|
|
|
-/* ------------------------------------------------------------------- */
|
|
|
-
|
|
|
-/* New functions for endianness conversion */
|
|
|
-#ifdef ANI_LITTLE_BYTE_ENDIAN
|
|
|
-#define ani_cpu_to_be16(x) sir_swap_u16((x))
|
|
|
-#define ani_cpu_to_le16(x) (x)
|
|
|
-#define ani_cpu_to_be32(x) sir_swap_u32((x))
|
|
|
-#define ani_cpu_to_le32(x) (x)
|
|
|
-#else /* ANI_LITTLE_BYTE_ENDIAN */
|
|
|
-#define ani_cpu_to_be16(x) (x)
|
|
|
-#define ani_cpu_to_le16(x) sir_swap_u16((x))
|
|
|
-#define ani_cpu_to_be32(x) (x)
|
|
|
-#define ani_cpu_to_le32(x) sir_swap_u32((x))
|
|
|
-#endif /* ANI_LITTLE_BYTE_ENDIAN */
|
|
|
-
|
|
|
-#define ani_le16_to_cpu(x) ani_cpu_to_le16(x)
|
|
|
-#define ani_le32_to_cpu(x) ani_cpu_to_le32(x)
|
|
|
-#define ani_be16_to_cpu(x) ani_cpu_to_be16(x)
|
|
|
-#define ani_be32_to_cpu(x) ani_cpu_to_be32(x)
|
|
|
-
|
|
|
#endif /* __UTILSAPI_H */
|