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 #include <net/cfg80211.h> 23 24 #include "qlink.h" 25 26 static inline void 27 qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len) 28 { 29 skb_put_data(skb, buf_src, len); 30 } 31 32 static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb, 33 u16 tlv_id, const u8 arr[], 34 size_t arr_len) 35 { 36 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len); 37 38 hdr->type = cpu_to_le16(tlv_id); 39 hdr->len = cpu_to_le16(arr_len); 40 memcpy(hdr->val, arr, arr_len); 41 } 42 43 static inline void qtnf_cmd_skb_put_tlv_tag(struct sk_buff *skb, u16 tlv_id) 44 { 45 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr)); 46 47 hdr->type = cpu_to_le16(tlv_id); 48 hdr->len = cpu_to_le16(0); 49 } 50 51 static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id, 52 u8 value) 53 { 54 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); 55 56 hdr->type = cpu_to_le16(tlv_id); 57 hdr->len = cpu_to_le16(sizeof(value)); 58 *hdr->val = value; 59 } 60 61 static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb, 62 u16 tlv_id, u16 value) 63 { 64 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); 65 __le16 tmp = cpu_to_le16(value); 66 67 hdr->type = cpu_to_le16(tlv_id); 68 hdr->len = cpu_to_le16(sizeof(value)); 69 memcpy(hdr->val, &tmp, sizeof(tmp)); 70 } 71 72 u16 qlink_iface_type_to_nl_mask(u16 qlink_type); 73 u8 qlink_chan_width_mask_to_nl(u16 qlink_mask); 74 void qlink_chandef_q2cfg(struct wiphy *wiphy, 75 const struct qlink_chandef *qch, 76 struct cfg80211_chan_def *chdef); 77 void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef, 78 struct qlink_chandef *qch); 79 enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val); 80 bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit, 81 unsigned int arr_max_len); 82 void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl, 83 struct qlink_acl_data *qacl); 84 85 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */ 86