2014-02-25 07:13:58

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH] ath10k: improve rx path when play with attention flags

Currently when we check attention flags we do __le32_to_cpu()
four times for each packet. This could have performance
impact for BIG endian platforms. This patch improve this
little bit.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath10k/htt_rx.c | 71 +++++-------------------------
1 file changed, 11 insertions(+), 60 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 316433f..97e4cd5 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -810,62 +810,6 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
ath10k_process_rx(htt->ar, info);
}

-static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb)
-{
- struct htt_rx_desc *rxd;
- u32 flags;
-
- rxd = (void *)skb->data - sizeof(*rxd);
- flags = __le32_to_cpu(rxd->attention.flags);
-
- if (flags & RX_ATTENTION_FLAGS_DECRYPT_ERR)
- return true;
-
- return false;
-}
-
-static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)
-{
- struct htt_rx_desc *rxd;
- u32 flags;
-
- rxd = (void *)skb->data - sizeof(*rxd);
- flags = __le32_to_cpu(rxd->attention.flags);
-
- if (flags & RX_ATTENTION_FLAGS_FCS_ERR)
- return true;
-
- return false;
-}
-
-static bool ath10k_htt_rx_has_mic_err(struct sk_buff *skb)
-{
- struct htt_rx_desc *rxd;
- u32 flags;
-
- rxd = (void *)skb->data - sizeof(*rxd);
- flags = __le32_to_cpu(rxd->attention.flags);
-
- if (flags & RX_ATTENTION_FLAGS_TKIP_MIC_ERR)
- return true;
-
- return false;
-}
-
-static bool ath10k_htt_rx_is_mgmt(struct sk_buff *skb)
-{
- struct htt_rx_desc *rxd;
- u32 flags;
-
- rxd = (void *)skb->data - sizeof(*rxd);
- flags = __le32_to_cpu(rxd->attention.flags);
-
- if (flags & RX_ATTENTION_FLAGS_MGMT_TYPE)
- return true;
-
- return false;
-}
-
static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb)
{
struct htt_rx_desc *rxd;
@@ -929,6 +873,9 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
struct sk_buff *msdu_head, *msdu_tail;
enum htt_rx_mpdu_status status;
int msdu_chaining;
+ struct htt_rx_desc *rxd;
+ u32 att_flags;
+

msdu_head = NULL;
msdu_tail = NULL;
@@ -950,7 +897,11 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
continue;
}

- if (ath10k_htt_rx_has_decrypt_err(msdu_head)) {
+ rxd = (void *)msdu_head->data - sizeof(*rxd);
+ att_flags = __le32_to_cpu(rxd->attention.flags);
+
+
+ if (att_flags & RX_ATTENTION_FLAGS_DECRYPT_ERR) {
ath10k_htt_rx_free_msdu_chain(msdu_head);
continue;
}
@@ -959,7 +910,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,

/* Skip mgmt frames while we handle this in WMI */
if (status == HTT_RX_IND_MPDU_STATUS_MGMT_CTRL ||
- ath10k_htt_rx_is_mgmt(msdu_head)) {
+ att_flags & RX_ATTENTION_FLAGS_MGMT_TYPE) {
ath10k_htt_rx_free_msdu_chain(msdu_head);
continue;
}
@@ -989,8 +940,8 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
}

info.skb = msdu_head;
- info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head);
- info.mic_err = ath10k_htt_rx_has_mic_err(msdu_head);
+ info.fcs_err = !!(att_flags & RX_ATTENTION_FLAGS_FCS_ERR);
+ info.mic_err = !!(att_flags & RX_ATTENTION_FLAGS_TKIP_MIC_ERR);
info.signal = ATH10K_DEFAULT_NOISE_FLOOR;
info.signal += rx->ppdu.combined_rssi;

--
1.7.9.5



2014-02-26 17:30:19

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] ath10k: improve rx path when play with attention flags

Michal Kazior <[email protected]> writes:

> On 25 February 2014 08:13, Janusz Dziedzic <[email protected]> wrote:
>> Currently when we check attention flags we do __le32_to_cpu()
>> four times for each packet. This could have performance
>> impact for BIG endian platforms. This patch improve this
>> little bit.
>>
>> Signed-off-by: Janusz Dziedzic <[email protected]>

[...]

>> @@ -929,6 +873,9 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
>> struct sk_buff *msdu_head, *msdu_tail;
>> enum htt_rx_mpdu_status status;
>> int msdu_chaining;
>> + struct htt_rx_desc *rxd;
>> + u32 att_flags;
>> +
>
> No need for an empty line I suppose? I would also prefer `attention`
> instead of `att_flags`, but no big deal.

Yeah, attention is better.

And also the variable declarations should be in the beginning of
function. Apparently I have been sloppy missed that here.

--
Kalle Valo

2014-02-25 07:24:51

by Michal Kazior

[permalink] [raw]
Subject: Re: [PATCH] ath10k: improve rx path when play with attention flags

On 25 February 2014 08:13, Janusz Dziedzic <[email protected]> wrote:
> Currently when we check attention flags we do __le32_to_cpu()
> four times for each packet. This could have performance
> impact for BIG endian platforms. This patch improve this
> little bit.
>
> Signed-off-by: Janusz Dziedzic <[email protected]>
> ---
> drivers/net/wireless/ath/ath10k/htt_rx.c | 71 +++++-------------------------
> 1 file changed, 11 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index 316433f..97e4cd5 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -810,62 +810,6 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
> ath10k_process_rx(htt->ar, info);
> }
>
> -static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb)
> -{
> - struct htt_rx_desc *rxd;
> - u32 flags;
> -
> - rxd = (void *)skb->data - sizeof(*rxd);
> - flags = __le32_to_cpu(rxd->attention.flags);
> -
> - if (flags & RX_ATTENTION_FLAGS_DECRYPT_ERR)
> - return true;
> -
> - return false;
> -}
> -
> -static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)
> -{
> - struct htt_rx_desc *rxd;
> - u32 flags;
> -
> - rxd = (void *)skb->data - sizeof(*rxd);
> - flags = __le32_to_cpu(rxd->attention.flags);
> -
> - if (flags & RX_ATTENTION_FLAGS_FCS_ERR)
> - return true;
> -
> - return false;
> -}
> -
> -static bool ath10k_htt_rx_has_mic_err(struct sk_buff *skb)
> -{
> - struct htt_rx_desc *rxd;
> - u32 flags;
> -
> - rxd = (void *)skb->data - sizeof(*rxd);
> - flags = __le32_to_cpu(rxd->attention.flags);
> -
> - if (flags & RX_ATTENTION_FLAGS_TKIP_MIC_ERR)
> - return true;
> -
> - return false;
> -}
> -
> -static bool ath10k_htt_rx_is_mgmt(struct sk_buff *skb)
> -{
> - struct htt_rx_desc *rxd;
> - u32 flags;
> -
> - rxd = (void *)skb->data - sizeof(*rxd);
> - flags = __le32_to_cpu(rxd->attention.flags);
> -
> - if (flags & RX_ATTENTION_FLAGS_MGMT_TYPE)
> - return true;
> -
> - return false;
> -}
> -
> static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb)
> {
> struct htt_rx_desc *rxd;
> @@ -929,6 +873,9 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
> struct sk_buff *msdu_head, *msdu_tail;
> enum htt_rx_mpdu_status status;
> int msdu_chaining;
> + struct htt_rx_desc *rxd;
> + u32 att_flags;
> +

No need for an empty line I suppose? I would also prefer `attention`
instead of `att_flags`, but no big deal.


> msdu_head = NULL;
> msdu_tail = NULL;
> @@ -950,7 +897,11 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
> continue;
> }
>
> - if (ath10k_htt_rx_has_decrypt_err(msdu_head)) {
> + rxd = (void *)msdu_head->data - sizeof(*rxd);

I think container_of(msdu_head->data, htt_tx_desc, msdu_payload) is a
better fit here :-)


> + att_flags = __le32_to_cpu(rxd->attention.flags);

Attention flags don't contain bitmasked values so we can skip the
conversion altogether here and do __cpu_to_le32() on the constant
values.


> +
> +

More empty lines?



MichaƂ