| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * Copyright (c) 2015-2016 Quantenna Communications, Inc. |
|---|
| 3 | | - * All rights reserved. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or |
|---|
| 6 | | - * modify it under the terms of the GNU General Public License |
|---|
| 7 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 8 | | - * of the License, or (at your option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - */ |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
|---|
| 2 | +/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */ |
|---|
| 16 | 3 | |
|---|
| 17 | 4 | #ifndef _QTN_FMAC_QLINK_UTIL_H_ |
|---|
| 18 | 5 | #define _QTN_FMAC_QLINK_UTIL_H_ |
|---|
| .. | .. |
|---|
| 33 | 20 | u16 tlv_id, const u8 arr[], |
|---|
| 34 | 21 | size_t arr_len) |
|---|
| 35 | 22 | { |
|---|
| 36 | | - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len); |
|---|
| 23 | + struct qlink_tlv_hdr *hdr; |
|---|
| 37 | 24 | |
|---|
| 25 | + hdr = skb_put(skb, sizeof(*hdr) + round_up(arr_len, QLINK_ALIGN)); |
|---|
| 38 | 26 | hdr->type = cpu_to_le16(tlv_id); |
|---|
| 39 | 27 | hdr->len = cpu_to_le16(arr_len); |
|---|
| 40 | 28 | memcpy(hdr->val, arr, arr_len); |
|---|
| 41 | 29 | } |
|---|
| 42 | 30 | |
|---|
| 43 | | -static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id, |
|---|
| 44 | | - u8 value) |
|---|
| 31 | +static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb, |
|---|
| 32 | + u16 tlv_id, u32 value) |
|---|
| 45 | 33 | { |
|---|
| 46 | 34 | struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); |
|---|
| 47 | | - |
|---|
| 48 | | - hdr->type = cpu_to_le16(tlv_id); |
|---|
| 49 | | - hdr->len = cpu_to_le16(sizeof(value)); |
|---|
| 50 | | - *hdr->val = value; |
|---|
| 51 | | -} |
|---|
| 52 | | - |
|---|
| 53 | | -static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb, |
|---|
| 54 | | - u16 tlv_id, u16 value) |
|---|
| 55 | | -{ |
|---|
| 56 | | - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); |
|---|
| 57 | | - __le16 tmp = cpu_to_le16(value); |
|---|
| 35 | + __le32 tmp = cpu_to_le32(value); |
|---|
| 58 | 36 | |
|---|
| 59 | 37 | hdr->type = cpu_to_le16(tlv_id); |
|---|
| 60 | 38 | hdr->len = cpu_to_le16(sizeof(value)); |
|---|
| .. | .. |
|---|
| 73 | 51 | unsigned int arr_max_len); |
|---|
| 74 | 52 | void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl, |
|---|
| 75 | 53 | struct qlink_acl_data *qacl); |
|---|
| 54 | +enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band); |
|---|
| 55 | +enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state); |
|---|
| 56 | +u32 qlink_utils_chflags_cfg2q(u32 cfgflags); |
|---|
| 57 | +void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule, |
|---|
| 58 | + const struct qlink_tlv_reg_rule *tlv_rule); |
|---|
| 59 | + |
|---|
| 60 | +#define qlink_for_each_tlv(_tlv, _start, _datalen) \ |
|---|
| 61 | + for (_tlv = (const struct qlink_tlv_hdr *)(_start); \ |
|---|
| 62 | + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ |
|---|
| 63 | + (int)sizeof(*_tlv) && \ |
|---|
| 64 | + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ |
|---|
| 65 | + (int)sizeof(*_tlv) + le16_to_cpu(_tlv->len); \ |
|---|
| 66 | + _tlv = (const struct qlink_tlv_hdr *)(_tlv->val + \ |
|---|
| 67 | + round_up(le16_to_cpu(_tlv->len), QLINK_ALIGN))) |
|---|
| 68 | + |
|---|
| 69 | +#define qlink_tlv_parsing_ok(_tlv_last, _start, _datalen) \ |
|---|
| 70 | + ((const u8 *)(_tlv_last) == \ |
|---|
| 71 | + (const u8 *)(_start) + round_up(_datalen, QLINK_ALIGN)) |
|---|
| 76 | 72 | |
|---|
| 77 | 73 | #endif /* _QTN_FMAC_QLINK_UTIL_H_ */ |
|---|