@@ -1193,8 +1193,7 @@ EXPORT_SYMBOL_GPL(mt7615_mac_enable_rtscts);
11931193static int
11941194mt7615_mac_wtbl_update_key (struct mt7615_dev * dev , struct mt76_wcid * wcid ,
11951195 struct ieee80211_key_conf * key ,
1196- enum mt76_cipher_type cipher , u16 cipher_mask ,
1197- enum set_key_cmd cmd )
1196+ enum mt76_cipher_type cipher , u16 cipher_mask )
11981197{
11991198 u32 addr = mt7615_mac_wtbl_addr (dev , wcid -> idx ) + 30 * 4 ;
12001199 u8 data [32 ] = {};
@@ -1203,27 +1202,18 @@ mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
12031202 return - EINVAL ;
12041203
12051204 mt76_rr_copy (dev , addr , data , sizeof (data ));
1206- if (cmd == SET_KEY ) {
1207- if (cipher == MT_CIPHER_TKIP ) {
1208- /* Rx/Tx MIC keys are swapped */
1209- memcpy (data , key -> key , 16 );
1210- memcpy (data + 16 , key -> key + 24 , 8 );
1211- memcpy (data + 24 , key -> key + 16 , 8 );
1212- } else {
1213- if (cipher_mask == BIT (cipher ))
1214- memcpy (data , key -> key , key -> keylen );
1215- else if (cipher != MT_CIPHER_BIP_CMAC_128 )
1216- memcpy (data , key -> key , 16 );
1217- if (cipher == MT_CIPHER_BIP_CMAC_128 )
1218- memcpy (data + 16 , key -> key , 16 );
1219- }
1205+ if (cipher == MT_CIPHER_TKIP ) {
1206+ /* Rx/Tx MIC keys are swapped */
1207+ memcpy (data , key -> key , 16 );
1208+ memcpy (data + 16 , key -> key + 24 , 8 );
1209+ memcpy (data + 24 , key -> key + 16 , 8 );
12201210 } else {
1211+ if (cipher_mask == BIT (cipher ))
1212+ memcpy (data , key -> key , key -> keylen );
1213+ else if (cipher != MT_CIPHER_BIP_CMAC_128 )
1214+ memcpy (data , key -> key , 16 );
12211215 if (cipher == MT_CIPHER_BIP_CMAC_128 )
1222- memset (data + 16 , 0 , 16 );
1223- else if (cipher_mask )
1224- memset (data , 0 , 16 );
1225- if (!cipher_mask )
1226- memset (data , 0 , sizeof (data ));
1216+ memcpy (data + 16 , key -> key , 16 );
12271217 }
12281218
12291219 mt76_wr_copy (dev , addr , data , sizeof (data ));
@@ -1234,7 +1224,7 @@ mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
12341224static int
12351225mt7615_mac_wtbl_update_pk (struct mt7615_dev * dev , struct mt76_wcid * wcid ,
12361226 enum mt76_cipher_type cipher , u16 cipher_mask ,
1237- int keyidx , enum set_key_cmd cmd )
1227+ int keyidx )
12381228{
12391229 u32 addr = mt7615_mac_wtbl_addr (dev , wcid -> idx ), w0 , w1 ;
12401230
@@ -1253,9 +1243,7 @@ mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid,
12531243 else
12541244 w0 &= ~MT_WTBL_W0_RX_IK_VALID ;
12551245
1256- if (cmd == SET_KEY &&
1257- (cipher != MT_CIPHER_BIP_CMAC_128 ||
1258- cipher_mask == BIT (cipher ))) {
1246+ if (cipher != MT_CIPHER_BIP_CMAC_128 || cipher_mask == BIT (cipher )) {
12591247 w0 &= ~MT_WTBL_W0_KEY_IDX ;
12601248 w0 |= FIELD_PREP (MT_WTBL_W0_KEY_IDX , keyidx );
12611249 }
@@ -1272,19 +1260,10 @@ mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid,
12721260
12731261static void
12741262mt7615_mac_wtbl_update_cipher (struct mt7615_dev * dev , struct mt76_wcid * wcid ,
1275- enum mt76_cipher_type cipher , u16 cipher_mask ,
1276- enum set_key_cmd cmd )
1263+ enum mt76_cipher_type cipher , u16 cipher_mask )
12771264{
12781265 u32 addr = mt7615_mac_wtbl_addr (dev , wcid -> idx );
12791266
1280- if (!cipher_mask ) {
1281- mt76_clear (dev , addr + 2 * 4 , MT_WTBL_W2_KEY_TYPE );
1282- return ;
1283- }
1284-
1285- if (cmd != SET_KEY )
1286- return ;
1287-
12881267 if (cipher == MT_CIPHER_BIP_CMAC_128 &&
12891268 cipher_mask & ~BIT (MT_CIPHER_BIP_CMAC_128 ))
12901269 return ;
@@ -1295,8 +1274,7 @@ mt7615_mac_wtbl_update_cipher(struct mt7615_dev *dev, struct mt76_wcid *wcid,
12951274
12961275int __mt7615_mac_wtbl_set_key (struct mt7615_dev * dev ,
12971276 struct mt76_wcid * wcid ,
1298- struct ieee80211_key_conf * key ,
1299- enum set_key_cmd cmd )
1277+ struct ieee80211_key_conf * key )
13001278{
13011279 enum mt76_cipher_type cipher ;
13021280 u16 cipher_mask = wcid -> cipher ;
@@ -1306,19 +1284,14 @@ int __mt7615_mac_wtbl_set_key(struct mt7615_dev *dev,
13061284 if (cipher == MT_CIPHER_NONE )
13071285 return - EOPNOTSUPP ;
13081286
1309- if (cmd == SET_KEY )
1310- cipher_mask |= BIT (cipher );
1311- else
1312- cipher_mask &= ~BIT (cipher );
1313-
1314- mt7615_mac_wtbl_update_cipher (dev , wcid , cipher , cipher_mask , cmd );
1315- err = mt7615_mac_wtbl_update_key (dev , wcid , key , cipher , cipher_mask ,
1316- cmd );
1287+ cipher_mask |= BIT (cipher );
1288+ mt7615_mac_wtbl_update_cipher (dev , wcid , cipher , cipher_mask );
1289+ err = mt7615_mac_wtbl_update_key (dev , wcid , key , cipher , cipher_mask );
13171290 if (err < 0 )
13181291 return err ;
13191292
13201293 err = mt7615_mac_wtbl_update_pk (dev , wcid , cipher , cipher_mask ,
1321- key -> keyidx , cmd );
1294+ key -> keyidx );
13221295 if (err < 0 )
13231296 return err ;
13241297
@@ -1329,13 +1302,12 @@ int __mt7615_mac_wtbl_set_key(struct mt7615_dev *dev,
13291302
13301303int mt7615_mac_wtbl_set_key (struct mt7615_dev * dev ,
13311304 struct mt76_wcid * wcid ,
1332- struct ieee80211_key_conf * key ,
1333- enum set_key_cmd cmd )
1305+ struct ieee80211_key_conf * key )
13341306{
13351307 int err ;
13361308
13371309 spin_lock_bh (& dev -> mt76 .lock );
1338- err = __mt7615_mac_wtbl_set_key (dev , wcid , key , cmd );
1310+ err = __mt7615_mac_wtbl_set_key (dev , wcid , key );
13391311 spin_unlock_bh (& dev -> mt76 .lock );
13401312
13411313 return err ;
0 commit comments