From: Kalle Valo <kvalo@codeaurora.org>
To: Aloka Dixit <alokad@codeaurora.org>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH V5 1/2] ath11k: add WMI calls to manually add/del/pause/resume TWT dialogs
Date: Tue, 09 Mar 2021 12:57:23 +0200 [thread overview]
Message-ID: <87sg54zjak.fsf@codeaurora.org> (raw)
In-Reply-To: <20210222192651.1782-2-alokad@codeaurora.org> (Aloka Dixit's message of "Mon, 22 Feb 2021 11:26:50 -0800")
Aloka Dixit <alokad@codeaurora.org> writes:
> From: John Crispin <john@phrozen.org>
>
> These calls are used for debugging and will be required for WFA
> certification tests.
>
> Signed-off-by: John Crispin <john@phrozen.org>
> Co-developed-by: Aloka Dixit <alokad@codeaurora.org>
> Signed-off-by: Aloka Dixit <alokad@codeaurora.org>
[...]
> +int ath11k_wmi_send_twt_add_dialog_cmd(struct ath11k *ar,
> + struct wmi_twt_add_dialog_params *params)
> +{
> + struct ath11k_pdev_wmi *wmi = ar->wmi;
> + struct ath11k_base *ab = wmi->wmi_ab->ab;
> + struct wmi_twt_add_dialog_params_cmd *cmd;
> + struct sk_buff *skb;
> + int ret, len;
> +
> + len = sizeof(*cmd);
> +
> + skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
> + if (!skb)
> + return -ENOMEM;
> +
> + cmd = (struct wmi_twt_add_dialog_params_cmd *)skb->data;
> + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_ADD_DIALOG_CMD) |
> + FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
> +
> + cmd->vdev_id = params->vdev_id;
> + ether_addr_copy(cmd->peer_macaddr.addr, params->peer_macaddr);
> + cmd->dialog_id = params->dialog_id;
> + cmd->wake_intvl_us = params->wake_intvl_us;
> + cmd->wake_intvl_mantis = params->wake_intvl_mantis;
> + cmd->wake_dura_us = params->wake_dura_us;
> + cmd->sp_offset_us = params->sp_offset_us;
> + cmd->flags = params->twt_cmd;
> + if (params->flag_bcast)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_BCAST;
> + if (params->flag_trigger)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_TRIGGER;
> + if (params->flag_flow_type)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_FLOW_TYPE;
> + if (params->flag_protection)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_PROTECTION;
> +
> + ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
> + "WMI add TWT dialog, vdev %u, dialog id %u,\n"
> + "wake interval %u, mantissa %u, wake duration %u,\n"
> + "service period offset %u, flags 0x%x\n",
In debug messages please use all lower case, and no commas nor \n (ie.
all in one line).
> + ret = ath11k_wmi_cmd_send(wmi, skb, WMI_TWT_ADD_DIALOG_CMDID);
> +
> + if (ret) {
> + ath11k_warn(ab,
> + "Failed to send WMI command to add TWT dialog\n");
Warning and error messages should follow style:
"failed to send add TWT dialog WMI command: %d", ret
> +static void ath11k_wmi_twt_add_dialog_event(struct ath11k_base *ab,
> + struct sk_buff *skb)
> +{
> + const char *status[] = {
> + "OK", "TWT_NOT_ENABLED", "USED_DIALOG_ID", "INVALID_PARAM",
> + "NOT_READY", "NO_RESOURCE", "NO_ACK", "NO_RESPONSE",
> + "DENIED", "UNKNOWN_ERROR"
> + };
> + const void **tb;
> + const struct wmi_twt_add_dialog_event *ev;
> + int ret;
> +
> + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
> + if (IS_ERR(tb)) {
> + ret = PTR_ERR(tb);
> + ath11k_warn(ab,
> + "failed to parse TWT add dialog status event tlv: %d\n", ret);
> + return;
> + }
> +
> + ev = tb[WMI_TAG_TWT_ADD_DIALOG_COMPLETE_EVENT];
> + if (!ev) {
> + ath11k_warn(ab, "failed to fetch TWT add dialog event\n");
> + goto exit;
> + }
> +
> + ath11k_dbg(ab, ATH11K_DBG_WMI,
> + "TWT Add Dialog Event - vdev: %d, dialog id: %d, status: %s\n",
> + ev->vdev_id, ev->dialog_id, status[ev->status]);
You are not checking that status array is not used out of bounds. I
would just remove the string conversion to keep things simple, but if
you want to print in strings please add a helper function to do the
conversion and add status values as enum to wmi.h.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
--
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k
WARNING: multiple messages have this Message-ID (diff)
From: Kalle Valo <kvalo@codeaurora.org>
To: Aloka Dixit <alokad@codeaurora.org>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH V5 1/2] ath11k: add WMI calls to manually add/del/pause/resume TWT dialogs
Date: Tue, 09 Mar 2021 12:57:23 +0200 [thread overview]
Message-ID: <87sg54zjak.fsf@codeaurora.org> (raw)
In-Reply-To: <20210222192651.1782-2-alokad@codeaurora.org> (Aloka Dixit's message of "Mon, 22 Feb 2021 11:26:50 -0800")
Aloka Dixit <alokad@codeaurora.org> writes:
> From: John Crispin <john@phrozen.org>
>
> These calls are used for debugging and will be required for WFA
> certification tests.
>
> Signed-off-by: John Crispin <john@phrozen.org>
> Co-developed-by: Aloka Dixit <alokad@codeaurora.org>
> Signed-off-by: Aloka Dixit <alokad@codeaurora.org>
[...]
> +int ath11k_wmi_send_twt_add_dialog_cmd(struct ath11k *ar,
> + struct wmi_twt_add_dialog_params *params)
> +{
> + struct ath11k_pdev_wmi *wmi = ar->wmi;
> + struct ath11k_base *ab = wmi->wmi_ab->ab;
> + struct wmi_twt_add_dialog_params_cmd *cmd;
> + struct sk_buff *skb;
> + int ret, len;
> +
> + len = sizeof(*cmd);
> +
> + skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
> + if (!skb)
> + return -ENOMEM;
> +
> + cmd = (struct wmi_twt_add_dialog_params_cmd *)skb->data;
> + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_ADD_DIALOG_CMD) |
> + FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
> +
> + cmd->vdev_id = params->vdev_id;
> + ether_addr_copy(cmd->peer_macaddr.addr, params->peer_macaddr);
> + cmd->dialog_id = params->dialog_id;
> + cmd->wake_intvl_us = params->wake_intvl_us;
> + cmd->wake_intvl_mantis = params->wake_intvl_mantis;
> + cmd->wake_dura_us = params->wake_dura_us;
> + cmd->sp_offset_us = params->sp_offset_us;
> + cmd->flags = params->twt_cmd;
> + if (params->flag_bcast)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_BCAST;
> + if (params->flag_trigger)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_TRIGGER;
> + if (params->flag_flow_type)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_FLOW_TYPE;
> + if (params->flag_protection)
> + cmd->flags |= WMI_TWT_ADD_DIALOG_FLAG_PROTECTION;
> +
> + ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
> + "WMI add TWT dialog, vdev %u, dialog id %u,\n"
> + "wake interval %u, mantissa %u, wake duration %u,\n"
> + "service period offset %u, flags 0x%x\n",
In debug messages please use all lower case, and no commas nor \n (ie.
all in one line).
> + ret = ath11k_wmi_cmd_send(wmi, skb, WMI_TWT_ADD_DIALOG_CMDID);
> +
> + if (ret) {
> + ath11k_warn(ab,
> + "Failed to send WMI command to add TWT dialog\n");
Warning and error messages should follow style:
"failed to send add TWT dialog WMI command: %d", ret
> +static void ath11k_wmi_twt_add_dialog_event(struct ath11k_base *ab,
> + struct sk_buff *skb)
> +{
> + const char *status[] = {
> + "OK", "TWT_NOT_ENABLED", "USED_DIALOG_ID", "INVALID_PARAM",
> + "NOT_READY", "NO_RESOURCE", "NO_ACK", "NO_RESPONSE",
> + "DENIED", "UNKNOWN_ERROR"
> + };
> + const void **tb;
> + const struct wmi_twt_add_dialog_event *ev;
> + int ret;
> +
> + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
> + if (IS_ERR(tb)) {
> + ret = PTR_ERR(tb);
> + ath11k_warn(ab,
> + "failed to parse TWT add dialog status event tlv: %d\n", ret);
> + return;
> + }
> +
> + ev = tb[WMI_TAG_TWT_ADD_DIALOG_COMPLETE_EVENT];
> + if (!ev) {
> + ath11k_warn(ab, "failed to fetch TWT add dialog event\n");
> + goto exit;
> + }
> +
> + ath11k_dbg(ab, ATH11K_DBG_WMI,
> + "TWT Add Dialog Event - vdev: %d, dialog id: %d, status: %s\n",
> + ev->vdev_id, ev->dialog_id, status[ev->status]);
You are not checking that status array is not used out of bounds. I
would just remove the string conversion to keep things simple, but if
you want to print in strings please add a helper function to do the
conversion and add status values as enum to wmi.h.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2021-03-09 10:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 19:26 [PATCH V5 0/2] WMI and debugfs calls for TWT dialogs Aloka Dixit
2021-02-22 19:26 ` Aloka Dixit
2021-02-22 19:26 ` [PATCH V5 1/2] ath11k: add WMI calls to manually add/del/pause/resume " Aloka Dixit
2021-02-22 19:26 ` Aloka Dixit
2021-03-09 10:50 ` Kalle Valo
2021-03-09 10:50 ` Kalle Valo
2021-03-09 10:57 ` Kalle Valo [this message]
2021-03-09 10:57 ` Kalle Valo
[not found] ` <20210309105025.72246C43462@smtp.codeaurora.org>
2021-03-10 18:42 ` Aloka Dixit
2021-03-10 18:42 ` Aloka Dixit
2021-03-11 6:01 ` Kalle Valo
2021-03-11 6:01 ` Kalle Valo
2021-02-22 19:26 ` [PATCH V5 2/2] ath11k: add debugfs for TWT debug calls Aloka Dixit
2021-02-22 19:26 ` Aloka Dixit
2021-03-09 10:59 ` Kalle Valo
2021-03-09 10:59 ` Kalle Valo
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=87sg54zjak.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=alokad@codeaurora.org \
--cc=ath11k@lists.infradead.org \
--cc=john@phrozen.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.