]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
networking: make skb_put & friends return void pointers
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / quantenna / qtnfmac / qlink_util.h
CommitLineData
98f44cb0
IM
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 */
16
17#ifndef _QTN_FMAC_QLINK_UTIL_H_
18#define _QTN_FMAC_QLINK_UTIL_H_
19
20#include <linux/types.h>
21#include <linux/skbuff.h>
22
23#include "qlink.h"
24
25static inline void qtnf_cmd_skb_put_action(struct sk_buff *skb, u16 action)
26{
27 __le16 *buf_ptr;
28
4df864c1 29 buf_ptr = skb_put(skb, sizeof(action));
98f44cb0
IM
30 *buf_ptr = cpu_to_le16(action);
31}
32
33static inline void
34qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
35{
36 u8 *buf_dst;
37
59ae1d12 38 buf_dst = skb_put_data(skb, buf_src, len);
98f44cb0
IM
39}
40
41static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
42 u16 tlv_id, const u8 arr[],
43 size_t arr_len)
44{
4df864c1 45 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
98f44cb0
IM
46
47 hdr->type = cpu_to_le16(tlv_id);
48 hdr->len = cpu_to_le16(arr_len);
49 memcpy(hdr->val, arr, arr_len);
50}
51
52static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
53 u8 value)
54{
4df864c1 55 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
98f44cb0
IM
56
57 hdr->type = cpu_to_le16(tlv_id);
58 hdr->len = cpu_to_le16(sizeof(value));
59 *hdr->val = value;
60}
61
62static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
63 u16 tlv_id, u16 value)
64{
4df864c1 65 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
98f44cb0
IM
66 __le16 tmp = cpu_to_le16(value);
67
68 hdr->type = cpu_to_le16(tlv_id);
69 hdr->len = cpu_to_le16(sizeof(value));
70 memcpy(hdr->val, &tmp, sizeof(tmp));
71}
72
73u16 qlink_iface_type_mask_to_nl(u16 qlink_mask);
74u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
75
76#endif /* _QTN_FMAC_QLINK_UTIL_H_ */