Skip to content
Snippets Groups Projects
Commit f4a60bee authored by Janusz Dziedzic's avatar Janusz Dziedzic
Browse files

wifi_opclass: add wifi_radio_opclass_update_channel

parent 9f5ffb53
Branches
No related tags found
1 merge request!295wifi_opclass: add wifi_radio_opclass_update_channel
......@@ -55,6 +55,7 @@ struct wifi_radio_opclass_channel {
struct wifi_radio_opclass_entry {
uint8_t id; /**< opclass id */
int bandwidth;
int band;
int max_txpower; /**< max allowed Tx power in dBm */
int num_channel;
struct wifi_radio_opclass_channel channel[64]; /**< channel list */
......
......@@ -18,6 +18,7 @@ static const struct wifi_radio_opclass e4 = {
.opclass = {
{
.id = 81,
.band = 2,
.bandwidth = 20,
.num_channel = 13,
.channel = {
......@@ -38,6 +39,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 82,
.band = 2,
.bandwidth = 20,
.num_channel = 1,
.channel = {
......@@ -46,6 +48,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 83,
.band = 2,
.bandwidth = 40,
.num_channel = 9,
.channel = {
......@@ -62,6 +65,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 84,
.band = 2,
.bandwidth = 40,
.num_channel = 9,
.channel = {
......@@ -78,6 +82,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 115,
.band = 5,
.bandwidth = 20,
.num_channel = 4,
.channel = {
......@@ -89,6 +94,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 116,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -98,6 +104,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 117,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -107,6 +114,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 118,
.band = 5,
.bandwidth = 20,
.num_channel = 4,
.channel = {
......@@ -118,6 +126,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 119,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -127,6 +136,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 120,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -137,6 +147,7 @@ static const struct wifi_radio_opclass e4 = {
{
.id = 121,
.bandwidth = 20,
.band = 5,
.num_channel = 12,
.channel = {
{ .channel = 100, .ctrl_channels = {100}},
......@@ -155,6 +166,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 122,
.band = 5,
.bandwidth = 40,
.num_channel = 6,
.channel = {
......@@ -168,6 +180,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 123,
.band = 5,
.bandwidth = 40,
.num_channel = 6,
.channel = {
......@@ -181,6 +194,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 124,
.band = 5,
.bandwidth = 40,
.num_channel = 4,
.channel = {
......@@ -192,6 +206,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 125,
.band = 5,
.bandwidth = 20,
.num_channel = 6,
.channel = {
......@@ -206,6 +221,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 126,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -216,6 +232,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 127,
.band = 5,
.bandwidth = 40,
.num_channel = 2,
.channel = {
......@@ -226,6 +243,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 128,
.band = 5,
.bandwidth = 80,
.num_channel = 6,
.channel = {
......@@ -239,6 +257,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 129,
.band = 5,
.bandwidth = 160,
.num_channel = 2,
.channel = {
......@@ -248,6 +267,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 130,
.band = 5,
.bandwidth = 80,
.num_channel = 6,
.channel = {
......@@ -261,6 +281,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 131,
.band = 6,
.bandwidth = 20,
.num_channel = 59,
.channel = {
......@@ -327,6 +348,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 132,
.band = 6,
.bandwidth = 40,
.num_channel = 29,
.channel = {
......@@ -363,6 +385,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 133,
.band = 6,
.bandwidth = 80,
.num_channel = 14,
.channel = {
......@@ -384,6 +407,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 134,
.band = 6,
.bandwidth = 160,
.num_channel = 7,
.channel = {
......@@ -398,6 +422,7 @@ static const struct wifi_radio_opclass e4 = {
},
{
.id = 135,
.band = 6,
.bandwidth = 80,
.num_channel = 14,
.channel = {
......@@ -825,6 +850,7 @@ uint8_t wifi_opclass_num_supported(struct wifi_radio_opclass *opclass)
static struct wifi_radio_opclass_channel *
wifi_opclass_find_opclass_channel(struct wifi_radio_opclass *opclass,
int band,
int ctrl_channel,
int bandwidth)
{
......@@ -835,6 +861,10 @@ wifi_opclass_find_opclass_channel(struct wifi_radio_opclass *opclass,
for (i = 0; i < opclass->num_opclass; i++) {
entry = &opclass->opclass[i];
/* Check band */
if (band && band != entry->band)
continue;
/* First check bandwidth */
if (entry->bandwidth != bandwidth)
continue;
......@@ -864,7 +894,7 @@ bool wifi_opclass_cac_required(struct wifi_radio_opclass *opclass,
{
struct wifi_radio_opclass_channel *channel;
channel = wifi_opclass_find_opclass_channel(opclass, ctrl_channel, bandwidth);
channel = wifi_opclass_find_opclass_channel(opclass, 5, ctrl_channel, bandwidth);
if (WARN_ON(!channel))
return false;
......@@ -1315,3 +1345,39 @@ struct wifi_radio_opclass_channel *wifi_opclass_get_channel(struct wifi_radio_op
return wifi_opclass_find_channel(entry, channel);
}
int wifi_radio_opclass_update_channel(struct wifi_radio_opclass *opclass, uint8_t band,
uint32_t channel, uint32_t bw, uint32_t pref)
{
struct wifi_radio_opclass_channel *channel_entry;
int bws[] = {20, 40, 80, 160, 320};
int i;
if (!bw) {
for (i = 0; i < ARRAY_SIZE(bws); i++) {
channel_entry = wifi_opclass_find_opclass_channel(opclass, band, channel, bws[i]);
if (!channel_entry)
continue;
channel_entry->preference = pref;
}
return 0;
}
channel_entry = wifi_opclass_find_opclass_channel(opclass, band, channel, bw);
if (!channel_entry)
return -1;
channel_entry->preference = pref;
/* Setup also 20MHz channel - so agent will know ctrl channel */
if (bw >= 80) {
channel_entry = wifi_opclass_find_opclass_channel(opclass, band, channel, 20);
if (!channel_entry)
return -1;
channel_entry->preference = pref;
}
return 0;
}
......@@ -57,4 +57,6 @@ void wifi_opclass_mark_unsupported(struct wifi_radio_opclass *out, struct wifi_r
enum wifi_band wifi_opclass_get_band(int opclass);
int wifi_opclass_get_bw(int op_class);
struct wifi_radio_opclass_channel *wifi_opclass_get_channel(struct wifi_radio_opclass *opclass, uint8_t id, uint8_t channel);
int wifi_radio_opclass_update_channel(struct wifi_radio_opclass *opclass, uint8_t band,
uint32_t channel, uint32_t bw, uint32_t pref);
#endif /* _WIFI_RADIO_OPCLASS_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment