From: Luciano Coelho <coelho@ti.com>
To: Eliad Peller <eliad@wizery.com>, eyal@wizery.com
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2 5/7] wl12xx: add RX data filter ACX commands
Date: Thu, 02 Feb 2012 10:23:03 +0200 [thread overview]
Message-ID: <1328170983.3626.265.camel@cumari> (raw)
In-Reply-To: <1328021048-8944-6-git-send-email-eliad@wizery.com>
On Tue, 2012-01-31 at 16:44 +0200, Eliad Peller wrote:
> From: Eyal Shapira <eyal@wizery.com>
>
> (based on Pontus' patch)
>
> Added commands for setting a specific filter
> and controlling the behaviour RX data filters
> implemented by the FW.
>
> Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
> Signed-off-by: Ido Reis <idor@ti.com>
> Signed-off-by: Eyal Shapira <eyal@wizery.com>
> Signed-off-by: Eliad Peller <eliad@wizery.com>
> ---
Why is Ido's sign-off here? (just curious)
> diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
> index bc96db0..668d337 100644
> --- a/drivers/net/wireless/wl12xx/acx.c
> +++ b/drivers/net/wireless/wl12xx/acx.c
> @@ -1740,3 +1740,108 @@ out:
> return ret;
>
> }
> +
> +int wl1271_acx_toggle_rx_data_filter(struct wl1271 *wl, bool enable,
> + u8 default_action)
Instead of "toggle" we usually have "enable" in the function name. This
is not very important, obviously, but if we get a v3 of this patch, you
could change it for a little more consistency. ;)
> {
> + struct acx_rx_data_filter_state *acx;
> + int ret;
> +
> + wl1271_debug(DEBUG_ACX, "acx toggle rx data filter en: %d act: %d",
> + enable, default_action);
> +
> + acx = kzalloc(sizeof(*acx), GFP_KERNEL);
> + if (!acx) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + acx->enable = enable ? 1 : 0;
Do we really need this? We usually trust that enable will be either true
(1) or false (0).
> +int wl1271_acx_set_rx_data_filter(struct wl1271 *wl, u8 index, bool enable,
> + struct wl12xx_rx_data_filter *filter)
> +{
> + struct acx_rx_data_filter_cfg *acx;
> + int fields_size = 0;
> + int acx_size;
> + int ret;
> +
> + if (enable && !filter) {
> + wl1271_warning("acx_set_rx_data_filter: enable but no filter");
> + return -EINVAL;
> + }
> +
> + if (index >= WL1271_MAX_RX_DATA_FILTERS) {
> + wl1271_warning("acx_set_rx_data_filter: invalid filter idx(%d)",
> + index);
> + return -EINVAL;
> + }
Should we use BUG_ON instead? This is only used internally in the
driver, so if it get here, it's a bug. And if the filters come from
userspace, we should validate them before continuing anyway.
> + if (filter) {
> + if (filter->action < FILTER_DROP ||
> + filter->action > FILTER_FW_HANDLE) {
> + wl1271_warning("invalid filter action (%d)",
> + filter->action);
> + return -EINVAL;
> + }
> +
> + if (filter->num_fields != 1 &&
> + filter->num_fields != 2) {
> + wl1271_warning("invalid filter num_fields (%d)",
> + filter->num_fields);
> + return -EINVAL;
> + }
Same for these two.
> + acx_size = roundup(sizeof(*acx) + fields_size, 4);
ALIGN()?
> + acx = kzalloc(acx_size, GFP_KERNEL);
> +
> + if (!acx)
> + return -ENOMEM;
> +
> + acx->enable = enable ? 1 : 0;
Same as above.
> diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
> index 1463341..c18ad0a 100644
> --- a/drivers/net/wireless/wl12xx/wl12xx.h
> +++ b/drivers/net/wireless/wl12xx/wl12xx.h
> @@ -277,6 +277,39 @@ struct wl1271_link {
> u8 ba_bitmap;
> };
>
> +#define WL1271_MAX_RX_DATA_FILTERS 4
> +#define WL1271_RX_DATA_FILTER_MAX_FIELD_PATTERNS 8
This is too long for a macro?
> +/* FW MAX FILTER SIZE is 98 bytes. The MAX_PATTERN_SIZE is imposed
> + * after taking into account the mask bytes and other structs members
> + */
This is slightly off according to the coding-style. ;)
Also s/structs/struct/
> +#define WL1271_RX_DATA_FILTER_MAX_PATTERN_SIZE 43
> +#define WL1271_RX_DATA_FILTER_ETH_HEADER_SIZE 14
> +
> +#define WL1271_RX_DATA_FILTER_FLAG_MASK BIT(0)
> +#define WL1271_RX_DATA_FILTER_FLAG_IP_HEADER 0
> +#define WL1271_RX_DATA_FILTER_FLAG_ETHERNET_HEADER BIT(1)
It would also be nice to find some smaller names for these.
> +struct wl12xx_rx_data_filter_field {
> + __le16 offset;
> + u8 len;
> + u8 flags;
> + u8 pattern[0];
> +} __packed;
> +
> +struct wl12xx_rx_data_filter {
> + u8 action;
> + int num_fields;
> + int fields_size;
> + struct wl12xx_rx_data_filter_field fields[0];
> +} __packed;
No need for __packed here. These are internal structs and not part of
the FW API.
--
Cheers,
Luca.
next prev parent reply other threads:[~2012-02-02 8:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 14:44 [PATCH v2 0/7] wl12xx: add some psm/suspend features Eliad Peller
2012-01-31 14:44 ` [PATCH v2 1/7] wl12xx: Set different wake up conditions in case of suspend Eliad Peller
2012-01-31 14:44 ` [PATCH v2 2/7] wl12xx: add suspend_listen_interval debugfs file Eliad Peller
2012-01-31 14:44 ` [PATCH v2 3/7] wl12xx: add forced_ps mode Eliad Peller
2012-02-02 7:43 ` Luciano Coelho
2012-01-31 14:44 ` [PATCH v2 4/7] wl12xx: add forced_ps debugfs file Eliad Peller
2012-02-02 7:44 ` Luciano Coelho
2012-02-02 8:09 ` Luciano Coelho
2012-01-31 14:44 ` [PATCH v2 5/7] wl12xx: add RX data filter ACX commands Eliad Peller
2012-02-02 8:23 ` Luciano Coelho [this message]
2012-02-06 14:07 ` Kalle Valo
2012-02-06 14:32 ` Luciano Coelho
2012-02-07 16:05 ` Kalle Valo
2012-02-07 16:11 ` Luciano Coelho
2012-01-31 14:44 ` [PATCH v2 6/7] wl12xx: add RX data filters management functions Eliad Peller
2012-02-02 8:39 ` Luciano Coelho
2012-01-31 14:44 ` [PATCH v2 7/7] wl12xx: support wowlan wakeup patterns Eliad Peller
2012-02-02 9:31 ` [PATCH v2 0/7] wl12xx: add some psm/suspend features Luciano Coelho
2012-02-02 9:45 ` Eliad Peller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328170983.3626.265.camel@cumari \
--to=coelho@ti.com \
--cc=eliad@wizery.com \
--cc=eyal@wizery.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox