2 * Copyright (c) 2015-2016 Quantenna Communications, Inc.
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.
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.
17 #ifndef _QTN_FMAC_QLINK_UTIL_H_
18 #define _QTN_FMAC_QLINK_UTIL_H_
20 #include <linux/types.h>
21 #include <linux/skbuff.h>
26 qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
28 skb_put_data(skb, buf_src, len);
31 static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
32 u16 tlv_id, const u8 arr[],
35 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
37 hdr->type = cpu_to_le16(tlv_id);
38 hdr->len = cpu_to_le16(arr_len);
39 memcpy(hdr->val, arr, arr_len);
42 static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
45 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
47 hdr->type = cpu_to_le16(tlv_id);
48 hdr->len = cpu_to_le16(sizeof(value));
52 static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
53 u16 tlv_id, u16 value)
55 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
56 __le16 tmp = cpu_to_le16(value);
58 hdr->type = cpu_to_le16(tlv_id);
59 hdr->len = cpu_to_le16(sizeof(value));
60 memcpy(hdr->val, &tmp, sizeof(tmp));
63 u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
64 u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
66 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */