Skip to content

Commit 868c36d

Browse files
committed
Merge tag 'wireless-drivers-next-for-davem-2018-01-26' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: ==================== wireless-drivers-next patches for 4.16 Major changes: wil6210 * add PCI device id for Talyn * support flashless device ath9k * improve RSSI/signal accuracy on AR9003 series mt76 * validate CCMP PN from received frames to avoid replay attacks qtnfmac * support 64-bit network stats * report more hardware information to kernel log and some via ethtool ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e7345ba + 30ce7f4 commit 868c36d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2213
-383
lines changed

drivers/net/wireless/ath/ath9k/ar9003_eeprom.c

Lines changed: 124 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,6 +3310,12 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
33103310
if (ar9300_check_eeprom_header(ah, read, cptr))
33113311
goto found;
33123312

3313+
cptr = AR9300_BASE_ADDR_4K;
3314+
ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
3315+
cptr);
3316+
if (ar9300_check_eeprom_header(ah, read, cptr))
3317+
goto found;
3318+
33133319
cptr = AR9300_BASE_ADDR_512;
33143320
ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
33153321
cptr);
@@ -3430,6 +3436,60 @@ static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
34303436
return len;
34313437
}
34323438

3439+
static u32 ar9003_dump_cal_data(struct ath_hw *ah, char *buf, u32 len, u32 size,
3440+
bool is_2g)
3441+
{
3442+
struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3443+
struct ar9300_base_eep_hdr *pBase;
3444+
struct ar9300_cal_data_per_freq_op_loop *cal_pier;
3445+
int cal_pier_nr;
3446+
int freq;
3447+
int i, j;
3448+
3449+
pBase = &eep->baseEepHeader;
3450+
3451+
if (is_2g)
3452+
cal_pier_nr = AR9300_NUM_2G_CAL_PIERS;
3453+
else
3454+
cal_pier_nr = AR9300_NUM_5G_CAL_PIERS;
3455+
3456+
for (i = 0; i < AR9300_MAX_CHAINS; i++) {
3457+
if (!((pBase->txrxMask >> i) & 1))
3458+
continue;
3459+
3460+
len += snprintf(buf + len, size - len, "Chain %d\n", i);
3461+
3462+
len += snprintf(buf + len, size - len,
3463+
"Freq\t ref\tvolt\ttemp\tnf_cal\tnf_pow\trx_temp\n");
3464+
3465+
for (j = 0; j < cal_pier_nr; j++) {
3466+
if (is_2g) {
3467+
cal_pier = &eep->calPierData2G[i][j];
3468+
freq = 2300 + eep->calFreqPier2G[j];
3469+
} else {
3470+
cal_pier = &eep->calPierData5G[i][j];
3471+
freq = 4800 + eep->calFreqPier5G[j] * 5;
3472+
}
3473+
3474+
len += snprintf(buf + len, size - len,
3475+
"%d\t", freq);
3476+
3477+
len += snprintf(buf + len, size - len,
3478+
"%d\t%d\t%d\t%d\t%d\t%d\n",
3479+
cal_pier->refPower,
3480+
cal_pier->voltMeas,
3481+
cal_pier->tempMeas,
3482+
cal_pier->rxTempMeas ?
3483+
N2DBM(cal_pier->rxNoisefloorCal) : 0,
3484+
cal_pier->rxTempMeas ?
3485+
N2DBM(cal_pier->rxNoisefloorPower) : 0,
3486+
cal_pier->rxTempMeas);
3487+
}
3488+
}
3489+
3490+
return len;
3491+
}
3492+
34333493
static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
34343494
u8 *buf, u32 len, u32 size)
34353495
{
@@ -3441,10 +3501,18 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
34413501
"%20s :\n", "2GHz modal Header");
34423502
len = ar9003_dump_modal_eeprom(buf, len, size,
34433503
&eep->modalHeader2G);
3444-
len += scnprintf(buf + len, size - len,
3504+
3505+
len += scnprintf(buf + len, size - len, "Calibration data\n");
3506+
len = ar9003_dump_cal_data(ah, buf, len, size, true);
3507+
3508+
len += snprintf(buf + len, size - len,
34453509
"%20s :\n", "5GHz modal Header");
34463510
len = ar9003_dump_modal_eeprom(buf, len, size,
34473511
&eep->modalHeader5G);
3512+
3513+
len += snprintf(buf + len, size - len, "Calibration data\n");
3514+
len = ar9003_dump_cal_data(ah, buf, len, size, false);
3515+
34483516
goto out;
34493517
}
34503518

@@ -4683,7 +4751,8 @@ static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
46834751
int ichain,
46844752
int *pfrequency,
46854753
int *pcorrection,
4686-
int *ptemperature, int *pvoltage)
4754+
int *ptemperature, int *pvoltage,
4755+
int *pnf_cal, int *pnf_power)
46874756
{
46884757
u8 *pCalPier;
46894758
struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
@@ -4725,6 +4794,10 @@ static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
47254794
*pcorrection = pCalPierStruct->refPower;
47264795
*ptemperature = pCalPierStruct->tempMeas;
47274796
*pvoltage = pCalPierStruct->voltMeas;
4797+
*pnf_cal = pCalPierStruct->rxTempMeas ?
4798+
N2DBM(pCalPierStruct->rxNoisefloorCal) : 0;
4799+
*pnf_power = pCalPierStruct->rxTempMeas ?
4800+
N2DBM(pCalPierStruct->rxNoisefloorPower) : 0;
47284801

47294802
return 0;
47304803
}
@@ -4889,14 +4962,18 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
48894962
int mode;
48904963
int lfrequency[AR9300_MAX_CHAINS],
48914964
lcorrection[AR9300_MAX_CHAINS],
4892-
ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS];
4965+
ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS],
4966+
lnf_cal[AR9300_MAX_CHAINS], lnf_pwr[AR9300_MAX_CHAINS];
48934967
int hfrequency[AR9300_MAX_CHAINS],
48944968
hcorrection[AR9300_MAX_CHAINS],
4895-
htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS];
4969+
htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS],
4970+
hnf_cal[AR9300_MAX_CHAINS], hnf_pwr[AR9300_MAX_CHAINS];
48964971
int fdiff;
48974972
int correction[AR9300_MAX_CHAINS],
4898-
voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS];
4899-
int pfrequency, pcorrection, ptemperature, pvoltage;
4973+
voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS],
4974+
nf_cal[AR9300_MAX_CHAINS], nf_pwr[AR9300_MAX_CHAINS];
4975+
int pfrequency, pcorrection, ptemperature, pvoltage,
4976+
pnf_cal, pnf_pwr;
49004977
struct ath_common *common = ath9k_hw_common(ah);
49014978

49024979
mode = (frequency >= 4000);
@@ -4914,7 +4991,8 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
49144991
for (ipier = 0; ipier < npier; ipier++) {
49154992
if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
49164993
&pfrequency, &pcorrection,
4917-
&ptemperature, &pvoltage)) {
4994+
&ptemperature, &pvoltage,
4995+
&pnf_cal, &pnf_pwr)) {
49184996
fdiff = frequency - pfrequency;
49194997

49204998
/*
@@ -4936,6 +5014,8 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
49365014
htemperature[ichain] =
49375015
ptemperature;
49385016
hvoltage[ichain] = pvoltage;
5017+
hnf_cal[ichain] = pnf_cal;
5018+
hnf_pwr[ichain] = pnf_pwr;
49395019
}
49405020
}
49415021
if (fdiff >= 0) {
@@ -4952,6 +5032,8 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
49525032
ltemperature[ichain] =
49535033
ptemperature;
49545034
lvoltage[ichain] = pvoltage;
5035+
lnf_cal[ichain] = pnf_cal;
5036+
lnf_pwr[ichain] = pnf_pwr;
49555037
}
49565038
}
49575039
}
@@ -4960,15 +5042,20 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
49605042

49615043
/* interpolate */
49625044
for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
4963-
ath_dbg(common, EEPROM, "ch=%d f=%d low=%d %d h=%d %d\n",
5045+
ath_dbg(common, EEPROM,
5046+
"ch=%d f=%d low=%d %d h=%d %d n=%d %d p=%d %d\n",
49645047
ichain, frequency, lfrequency[ichain],
49655048
lcorrection[ichain], hfrequency[ichain],
4966-
hcorrection[ichain]);
5049+
hcorrection[ichain], lnf_cal[ichain],
5050+
hnf_cal[ichain], lnf_pwr[ichain],
5051+
hnf_pwr[ichain]);
49675052
/* they're the same, so just pick one */
49685053
if (hfrequency[ichain] == lfrequency[ichain]) {
49695054
correction[ichain] = lcorrection[ichain];
49705055
voltage[ichain] = lvoltage[ichain];
49715056
temperature[ichain] = ltemperature[ichain];
5057+
nf_cal[ichain] = lnf_cal[ichain];
5058+
nf_pwr[ichain] = lnf_pwr[ichain];
49725059
}
49735060
/* the low frequency is good */
49745061
else if (frequency - lfrequency[ichain] < 1000) {
@@ -4992,23 +5079,41 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
49925079
hfrequency[ichain],
49935080
lvoltage[ichain],
49945081
hvoltage[ichain]);
5082+
5083+
nf_cal[ichain] = interpolate(frequency,
5084+
lfrequency[ichain],
5085+
hfrequency[ichain],
5086+
lnf_cal[ichain],
5087+
hnf_cal[ichain]);
5088+
5089+
nf_pwr[ichain] = interpolate(frequency,
5090+
lfrequency[ichain],
5091+
hfrequency[ichain],
5092+
lnf_pwr[ichain],
5093+
hnf_pwr[ichain]);
49955094
}
49965095
/* only low is good, use it */
49975096
else {
49985097
correction[ichain] = lcorrection[ichain];
49995098
temperature[ichain] = ltemperature[ichain];
50005099
voltage[ichain] = lvoltage[ichain];
5100+
nf_cal[ichain] = lnf_cal[ichain];
5101+
nf_pwr[ichain] = lnf_pwr[ichain];
50015102
}
50025103
}
50035104
/* only high is good, use it */
50045105
else if (hfrequency[ichain] - frequency < 1000) {
50055106
correction[ichain] = hcorrection[ichain];
50065107
temperature[ichain] = htemperature[ichain];
50075108
voltage[ichain] = hvoltage[ichain];
5109+
nf_cal[ichain] = hnf_cal[ichain];
5110+
nf_pwr[ichain] = hnf_pwr[ichain];
50085111
} else { /* nothing is good, presume 0???? */
50095112
correction[ichain] = 0;
50105113
temperature[ichain] = 0;
50115114
voltage[ichain] = 0;
5115+
nf_cal[ichain] = 0;
5116+
nf_pwr[ichain] = 0;
50125117
}
50135118
}
50145119

@@ -5019,6 +5124,16 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
50195124
"for frequency=%d, calibration correction = %d %d %d\n",
50205125
frequency, correction[0], correction[1], correction[2]);
50215126

5127+
/* Store calibrated noise floor values */
5128+
for (ichain = 0; ichain < AR5416_MAX_CHAINS; ichain++)
5129+
if (mode) {
5130+
ah->nf_5g.cal[ichain] = nf_cal[ichain];
5131+
ah->nf_5g.pwr[ichain] = nf_pwr[ichain];
5132+
} else {
5133+
ah->nf_2g.cal[ichain] = nf_cal[ichain];
5134+
ah->nf_2g.pwr[ichain] = nf_pwr[ichain];
5135+
}
5136+
50225137
return 0;
50235138
}
50245139

drivers/net/wireless/ath/ath9k/ar9003_eeprom.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@
6262
*/
6363
#define AR9300_PWR_TABLE_OFFSET 0
6464

65+
/* Noise power data definitions
66+
* units are: 4 x dBm - NOISE_PWR_DATA_OFFSET
67+
* (e.g. -25 = (-25/4 - 90) = -96.25 dBm)
68+
* range (for 6 signed bits) is (-32 to 31) + offset => -122dBm to -59dBm
69+
* resolution (2 bits) is 0.25dBm
70+
*/
71+
#define NOISE_PWR_DATA_OFFSET -90
72+
#define NOISE_PWR_DBM_2_INT(_p) ((((_p) + 3) >> 2) + NOISE_PWR_DATA_OFFSET)
73+
#define N2DBM(_p) NOISE_PWR_DBM_2_INT(_p)
74+
6575
/* byte addressable */
6676
#define AR9300_EEPROM_SIZE (16*1024)
6777

drivers/net/wireless/ath/ath9k/calib.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,25 @@ static struct ath_nf_limits *ath9k_hw_get_nf_limits(struct ath_hw *ah,
5858
}
5959

6060
static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
61-
struct ath9k_channel *chan)
61+
struct ath9k_channel *chan,
62+
int chain)
6263
{
63-
return ath9k_hw_get_nf_limits(ah, chan)->nominal;
64+
s16 calib_nf = ath9k_hw_get_nf_limits(ah, chan)->cal[chain];
65+
66+
if (calib_nf)
67+
return calib_nf;
68+
else
69+
return ath9k_hw_get_nf_limits(ah, chan)->nominal;
6470
}
6571

6672
s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan,
6773
s16 nf)
6874
{
69-
s8 noise = ATH_DEFAULT_NOISE_FLOOR;
75+
s8 noise = ath9k_hw_get_default_nf(ah, chan, 0);
7076

7177
if (nf) {
7278
s8 delta = nf - ATH9K_NF_CAL_NOISE_THRESH -
73-
ath9k_hw_get_default_nf(ah, chan);
79+
ath9k_hw_get_default_nf(ah, chan, 0);
7480
if (delta > 0)
7581
noise += delta;
7682
}
@@ -240,7 +246,7 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
240246
unsigned i, j;
241247
u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
242248
struct ath_common *common = ath9k_hw_common(ah);
243-
s16 default_nf = ath9k_hw_get_default_nf(ah, chan);
249+
s16 default_nf = ath9k_hw_get_nf_limits(ah, chan)->nominal;
244250
u32 bb_agc_ctl = REG_READ(ah, AR_PHY_AGC_CONTROL);
245251

246252
if (ah->caldata)
@@ -258,8 +264,13 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
258264
nfval = ah->nf_override;
259265
else if (h)
260266
nfval = h[i].privNF;
261-
else
262-
nfval = default_nf;
267+
else {
268+
/* Try to get calibrated noise floor value */
269+
nfval =
270+
ath9k_hw_get_nf_limits(ah, chan)->cal[i];
271+
if (nfval > -60 || nfval < -127)
272+
nfval = default_nf;
273+
}
263274

264275
REG_RMW(ah, ah->nf_regs[i],
265276
(((u32) nfval << 1) & 0x1ff), 0x1ff);
@@ -429,20 +440,19 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
429440
struct ath9k_channel *chan)
430441
{
431442
struct ath9k_nfcal_hist *h;
432-
s16 default_nf;
433-
int i, j;
443+
int i, j, k = 0;
434444

435445
ah->caldata->channel = chan->channel;
436446
ah->caldata->channelFlags = chan->channelFlags;
437447
h = ah->caldata->nfCalHist;
438-
default_nf = ath9k_hw_get_default_nf(ah, chan);
439448
for (i = 0; i < NUM_NF_READINGS; i++) {
440449
h[i].currIndex = 0;
441-
h[i].privNF = default_nf;
450+
h[i].privNF = ath9k_hw_get_default_nf(ah, chan, k);
442451
h[i].invalidNFcount = AR_PHY_CCA_FILTERWINDOW_LENGTH;
443-
for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
444-
h[i].nfCalBuffer[j] = default_nf;
445-
}
452+
for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++)
453+
h[i].nfCalBuffer[j] = h[i].privNF;
454+
if (++k >= AR5416_MAX_CHAINS)
455+
k = 0;
446456
}
447457
}
448458

drivers/net/wireless/ath/ath9k/hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ struct ath_nf_limits {
754754
s16 max;
755755
s16 min;
756756
s16 nominal;
757+
s16 cal[AR5416_MAX_CHAINS];
758+
s16 pwr[AR5416_MAX_CHAINS];
757759
};
758760

759761
enum ath_cal_list {

drivers/net/wireless/ath/ath9k/recv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,9 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
826826
sc->rx.discard_next = false;
827827

828828
/*
829-
* Discard zero-length packets.
829+
* Discard zero-length packets and packets smaller than an ACK
830830
*/
831-
if (!rx_stats->rs_datalen) {
831+
if (rx_stats->rs_datalen < 10) {
832832
RX_STAT_INC(rx_len_err);
833833
goto corrupt;
834834
}

0 commit comments

Comments
 (0)