198f44cb0SIgor Mitsyanko /* 298f44cb0SIgor Mitsyanko * Copyright (c) 2015-2016 Quantenna Communications, Inc. 398f44cb0SIgor Mitsyanko * 498f44cb0SIgor Mitsyanko * This program is free software; you can redistribute it and/or 598f44cb0SIgor Mitsyanko * modify it under the terms of the GNU General Public License 698f44cb0SIgor Mitsyanko * as published by the Free Software Foundation; either version 2 798f44cb0SIgor Mitsyanko * of the License, or (at your option) any later version. 898f44cb0SIgor Mitsyanko * 998f44cb0SIgor Mitsyanko * This program is distributed in the hope that it will be useful, 1098f44cb0SIgor Mitsyanko * but WITHOUT ANY WARRANTY; without even the implied warranty of 1198f44cb0SIgor Mitsyanko * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1298f44cb0SIgor Mitsyanko * GNU General Public License for more details. 1398f44cb0SIgor Mitsyanko * 1498f44cb0SIgor Mitsyanko */ 1598f44cb0SIgor Mitsyanko 1698f44cb0SIgor Mitsyanko #include <linux/nl80211.h> 1798f44cb0SIgor Mitsyanko 1898f44cb0SIgor Mitsyanko #include "qlink_util.h" 1998f44cb0SIgor Mitsyanko 2098f44cb0SIgor Mitsyanko u16 qlink_iface_type_mask_to_nl(u16 qlink_mask) 2198f44cb0SIgor Mitsyanko { 2298f44cb0SIgor Mitsyanko u16 result = 0; 2398f44cb0SIgor Mitsyanko 2498f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_IFTYPE_AP) 2598f44cb0SIgor Mitsyanko result |= BIT(NL80211_IFTYPE_AP); 2698f44cb0SIgor Mitsyanko 2798f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_IFTYPE_STATION) 2898f44cb0SIgor Mitsyanko result |= BIT(NL80211_IFTYPE_STATION); 2998f44cb0SIgor Mitsyanko 3098f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_IFTYPE_ADHOC) 3198f44cb0SIgor Mitsyanko result |= BIT(NL80211_IFTYPE_ADHOC); 3298f44cb0SIgor Mitsyanko 3398f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_IFTYPE_MONITOR) 3498f44cb0SIgor Mitsyanko result |= BIT(NL80211_IFTYPE_MONITOR); 3598f44cb0SIgor Mitsyanko 3698f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_IFTYPE_WDS) 3798f44cb0SIgor Mitsyanko result |= BIT(NL80211_IFTYPE_WDS); 3898f44cb0SIgor Mitsyanko 3998f44cb0SIgor Mitsyanko return result; 4098f44cb0SIgor Mitsyanko } 4198f44cb0SIgor Mitsyanko 4298f44cb0SIgor Mitsyanko u8 qlink_chan_width_mask_to_nl(u16 qlink_mask) 4398f44cb0SIgor Mitsyanko { 4498f44cb0SIgor Mitsyanko u8 result = 0; 4598f44cb0SIgor Mitsyanko 4698f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_5) 4798f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_5); 4898f44cb0SIgor Mitsyanko 4998f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_10) 5098f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_10); 5198f44cb0SIgor Mitsyanko 5298f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_20_NOHT) 5398f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_20_NOHT); 5498f44cb0SIgor Mitsyanko 5598f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_20) 5698f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_20); 5798f44cb0SIgor Mitsyanko 5898f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_40) 5998f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_40); 6098f44cb0SIgor Mitsyanko 6198f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_80) 6298f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_80); 6398f44cb0SIgor Mitsyanko 6498f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_80P80) 6598f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_80P80); 6698f44cb0SIgor Mitsyanko 6798f44cb0SIgor Mitsyanko if (qlink_mask & QLINK_CHAN_WIDTH_160) 6898f44cb0SIgor Mitsyanko result |= BIT(NL80211_CHAN_WIDTH_160); 6998f44cb0SIgor Mitsyanko 7098f44cb0SIgor Mitsyanko return result; 7198f44cb0SIgor Mitsyanko } 72