2019-01-14 16:39:45 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
|
2017-05-12 04:51:01 +07:00
|
|
|
|
|
|
|
#ifndef _QTN_FMAC_QLINK_UTIL_H_
|
|
|
|
#define _QTN_FMAC_QLINK_UTIL_H_
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/skbuff.h>
|
2017-09-22 04:34:30 +07:00
|
|
|
#include <net/cfg80211.h>
|
2017-05-12 04:51:01 +07:00
|
|
|
|
|
|
|
#include "qlink.h"
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
|
|
|
|
{
|
2017-06-18 21:52:04 +07:00
|
|
|
skb_put_data(skb, buf_src, len);
|
2017-05-12 04:51:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
|
|
|
|
u16 tlv_id, const u8 arr[],
|
|
|
|
size_t arr_len)
|
|
|
|
{
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 19:29:21 +07:00
|
|
|
struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
|
2017-05-12 04:51:01 +07:00
|
|
|
|
|
|
|
hdr->type = cpu_to_le16(tlv_id);
|
|
|
|
hdr->len = cpu_to_le16(arr_len);
|
|
|
|
memcpy(hdr->val, arr, arr_len);
|
|
|
|
}
|
|
|
|
|
2018-10-05 17:11:41 +07:00
|
|
|
static inline void qtnf_cmd_skb_put_tlv_tag(struct sk_buff *skb, u16 tlv_id)
|
|
|
|
{
|
|
|
|
struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr));
|
|
|
|
|
|
|
|
hdr->type = cpu_to_le16(tlv_id);
|
|
|
|
hdr->len = cpu_to_le16(0);
|
|
|
|
}
|
|
|
|
|
2017-05-12 04:51:01 +07:00
|
|
|
static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
|
|
|
|
u8 value)
|
|
|
|
{
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 19:29:21 +07:00
|
|
|
struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
|
2017-05-12 04:51:01 +07:00
|
|
|
|
|
|
|
hdr->type = cpu_to_le16(tlv_id);
|
|
|
|
hdr->len = cpu_to_le16(sizeof(value));
|
|
|
|
*hdr->val = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
|
|
|
|
u16 tlv_id, u16 value)
|
|
|
|
{
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 19:29:21 +07:00
|
|
|
struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
|
2017-05-12 04:51:01 +07:00
|
|
|
__le16 tmp = cpu_to_le16(value);
|
|
|
|
|
|
|
|
hdr->type = cpu_to_le16(tlv_id);
|
|
|
|
hdr->len = cpu_to_le16(sizeof(value));
|
|
|
|
memcpy(hdr->val, &tmp, sizeof(tmp));
|
|
|
|
}
|
|
|
|
|
2019-01-14 16:39:40 +07:00
|
|
|
static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb,
|
|
|
|
u16 tlv_id, u32 value)
|
|
|
|
{
|
|
|
|
struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
|
|
|
|
__le32 tmp = cpu_to_le32(value);
|
|
|
|
|
|
|
|
hdr->type = cpu_to_le16(tlv_id);
|
|
|
|
hdr->len = cpu_to_le16(sizeof(value));
|
|
|
|
memcpy(hdr->val, &tmp, sizeof(tmp));
|
|
|
|
}
|
|
|
|
|
2017-07-28 06:06:52 +07:00
|
|
|
u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
|
2017-05-12 04:51:01 +07:00
|
|
|
u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
|
2017-09-22 04:34:30 +07:00
|
|
|
void qlink_chandef_q2cfg(struct wiphy *wiphy,
|
|
|
|
const struct qlink_chandef *qch,
|
|
|
|
struct cfg80211_chan_def *chdef);
|
2017-10-05 08:38:08 +07:00
|
|
|
void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef,
|
|
|
|
struct qlink_chandef *qch);
|
2017-10-05 08:38:07 +07:00
|
|
|
enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val);
|
2017-12-19 18:28:54 +07:00
|
|
|
bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit,
|
|
|
|
unsigned int arr_max_len);
|
2017-12-19 18:28:56 +07:00
|
|
|
void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
|
|
|
|
struct qlink_acl_data *qacl);
|
2017-05-12 04:51:01 +07:00
|
|
|
|
|
|
|
#endif /* _QTN_FMAC_QLINK_UTIL_H_ */
|