add preliminary usb support to mt7615 driver
Subsystems (2)
Lorenzo Bianconi
maintainercover add preliminary usb support to mt7615 driver
This is the first preliminary series to add support to mt7663u driver This series is based on 'mt7663 driver update'
https://patchwork.kernel.org/cover/11470699/
Lorenzo Bianconi (9):
mt76: add headroom and tailroom to mt76_mcu_ops data structure
mt76: mt7615: introduce mt7663u support to mt7615_write_txwi
mt76: mt7615: introduce mt7615_mac_update_rate_desc routine
mt76: mt7615: introduce __mt7663_load_firmware routine
mt76: mt7615: move mt7615_mac_wtbl_addr in mac.h
mt76: mt76u: rely on mt7622 queue scheme for mt7663u
mt76: mt7615: rework wtbl key configuration
mt76: mt7615: introuce mt7615_wtbl_desc data structure
mt76: mt7615: add address parameter to mt7615_eeprom_init
drivers/net/wireless/mediatek/mt76/mcu.c | 9 +- drivers/net/wireless/mediatek/mt76/mt76.h | 7 +- .../net/wireless/mediatek/mt76/mt7603/mcu.c | 3 +- .../net/wireless/mediatek/mt76/mt7603/mcu.h | 7 - .../wireless/mediatek/mt76/mt7615/eeprom.c | 12 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7615/mac.c | 187 +++++++++--------- .../net/wireless/mediatek/mt76/mt7615/mac.h | 33 ++++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 85 ++++---- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 7 - .../wireless/mediatek/mt76/mt7615/mt7615.h | 50 ++++- .../net/wireless/mediatek/mt76/mt76x02_mcu.c | 2 +- .../net/wireless/mediatek/mt76/mt76x02_mcu.h | 6 - .../wireless/mediatek/mt76/mt76x02_usb_mcu.c | 4 +- drivers/net/wireless/mediatek/mt76/usb.c | 15 +- 15 files changed, 260 insertions(+), 170 deletions(-)
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 1/9 mt76: add headroom and tailroom to mt76_mcu_ops data structure
Introduce headroom and tailroom to mt76_mcu_ops data structure in order to unify the routine used for mcu message allocation. This is a preliminary patch to add mt7663u support
--- drivers/net/wireless/mediatek/mt76/mcu.c | 9 +-- drivers/net/wireless/mediatek/mt76/mt76.h | 7 ++- .../net/wireless/mediatek/mt76/mt7603/mcu.c | 3 +- .../net/wireless/mediatek/mt76/mt7603/mcu.h | 7 --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 63 ++++++++++--------- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 7 --- .../net/wireless/mediatek/mt76/mt76x02_mcu.c | 2 +- .../net/wireless/mediatek/mt76/mt76x02_mcu.h | 6 -- .../wireless/mediatek/mt76/mt76x02_usb_mcu.c | 4 +- 9 files changed, 51 insertions(+), 57 deletions(-)
drivers/net/wireless/mediatek/mt76/mcu.c +5 -4
@@ -6,10 +6,11 @@#include "mt76.h" struct sk_buff * -mt76_mcu_msg_alloc (const void *data,int head_len, -int data_len,int tail_len) +mt76_mcu_msg_alloc (struct mt76_dev *dev,const void *data, +int data_len) { -int length = head_len + data_len + tail_len; +const struct mt76_mcu_ops *ops = dev->mcu_ops; +int length = ops->headroom + data_len + ops->tailroom;struct sk_buff *skb; skb =alloc_skb (length,GFP_KERNEL );
@@ -17,7 +18,7 @@ mt76_mcu_msg_alloc(const void *data, int head_len,return NULL ;memset (skb->head,0 , length); -skb_reserve (skb, head_len); +skb_reserve (skb, ops->headroom);if (data && data_len)skb_put_data (skb, data, data_len);
drivers/net/wireless/mediatek/mt76/mt76.h +5 -2
@@ -137,6 +137,9 @@ struct mt76_sw_queue { };struct mt76_mcu_ops { +u32 headroom; +u32 tailroom; +int (*mcu_send_msg)(struct mt76_dev *dev,int cmd,const void *data,int len,bool wait_resp); int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
@@ -914,8 +917,8 @@ int mt76u_resume_rx(struct mt76_dev *dev);void mt76u_queues_deinit (struct mt76_dev *dev);struct sk_buff * -mt76_mcu_msg_alloc (const void *data,int head_len, -int data_len,int tail_len); +mt76_mcu_msg_alloc (struct mt76_dev *dev,const void *data, +int data_len);void mt76_mcu_rx_event (struct mt76_dev *dev,struct sk_buff *skb);struct sk_buff *mt76_mcu_get_response (struct mt76_dev *dev,unsigned long expires);
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +2 -1
@@ -62,7 +62,7 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,struct sk_buff *skb;int ret, seq; - skb =mt7603_mcu_msg_alloc (data, len); + skb =mt76_mcu_msg_alloc (mdev, data, len);if (!skb)return -ENOMEM ;
@@ -265,6 +265,7 @@ static int mt7603_load_firmware(struct mt7603_dev *dev)int mt7603_mcu_init (struct mt7603_dev *dev) {static const struct mt76_mcu_ops mt7603_mcu_ops = { + .headroom =sizeof (struct mt7603_mcu_txd ), .mcu_send_msg = mt7603_mcu_msg_send, .mcu_restart = mt7603_mcu_restart, };
drivers/net/wireless/mediatek/mt76/mt7603/mcu.h +0 -7
@@ -100,11 +100,4 @@ enum { MCU_EXT_EVENT_BCN_UPDATE = 0x31, }; -static inline struct sk_buff * -mt7603_mcu_msg_alloc (const void *data,int len) -{ -return mt76_mcu_msg_alloc (data,sizeof (struct mt7603_mcu_txd ), - len,0 ); -} -#endif
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +35 -28
223 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h +0 -7
@@ -845,11 +845,4 @@ enum {CH_SWITCH_SCAN_BYPASS_DPD =9 }; -static inline struct sk_buff * -mt7615_mcu_msg_alloc (const void *data,int len) -{ -return mt76_mcu_msg_alloc (data,sizeof (struct mt7615_mcu_txd ), - len,0 ); -} -#endif
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c +1 -1
@@ -23,7 +23,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,if (mt76_is_mmio (&dev->mt76) && dev->mcu_timeout)return -EIO ; - skb =mt76x02_mcu_msg_alloc (data, len); + skb =mt76_mcu_msg_alloc (mdev, data, len);if (!skb)return -ENOMEM ;
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h +0 -6
@@ -85,12 +85,6 @@ struct mt76x02_patch_header {u8 pad[2 ]; }; -static inline struct sk_buff * -mt76x02_mcu_msg_alloc (const void *data,int len) -{ -return mt76_mcu_msg_alloc (data,0 , len,0 ); -} -int mt76x02_mcu_cleanup (struct mt76x02_dev *dev);int mt76x02_mcu_calibrate (struct mt76x02_dev *dev,int type,u32 param); int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c +3 -1
@@ -123,7 +123,7 @@ mt76x02u_mcu_send_msg(struct mt76_dev *dev, int cmd, const void *data,struct sk_buff *skb;int err; - skb =mt76_mcu_msg_alloc (data,MT_CMD_HDR_LEN , len,8 ); + skb =mt76_mcu_msg_alloc (dev, data, len);if (!skb)return -ENOMEM ;
@@ -291,6 +291,8 @@ EXPORT_SYMBOL_GPL(mt76x02u_mcu_fw_send_data);void mt76x02u_init_mcu (struct mt76_dev *dev) {static const struct mt76_mcu_ops mt76x02u_mcu_ops = { + .headroom =MT_CMD_HDR_LEN , + .tailroom =8 , .mcu_send_msg = mt76x02u_mcu_send_msg, .mcu_wr_rp = mt76x02u_mcu_wr_rp, .mcu_rd_rp = mt76x02u_mcu_rd_rp,
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 2/9 mt76: mt7615: introduce mt7663u support to mt7615_write_txwi
In reply to Lorenzo BianconiExtend mt7615_write_txwi routine to support usb txwi configuration
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 12 ++++++++---- drivers/net/wireless/mediatek/mt76/mt7615/mac.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +8 -4
@@ -526,11 +526,12 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,struct ieee80211_vif *vif = info->control.vif;struct mt76_phy *mphy = &dev->mphy;bool ext_phy = info->hw_queue &MT_TX_HW_QUEUE_EXT_PHY ; +bool is_usb =mt76_is_usb (&dev->mt76);int tx_count =8 ;u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx =0 , wmm_idx =0 ;__le16 fc = hdr->frame_control; +u32 val, sz_txd = is_usb ?MT_USB_TXD_SIZE :MT_TXD_SIZE ;u16 seqno =0 ; -u32 val;if (vif) {struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
@@ -554,7 +555,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,if (ieee80211_is_data (fc) ||ieee80211_is_bufferable_mmpdu (fc)) { q_idx = wmm_idx *MT7615_MAX_WMM_SETS +skb_get_queue_mapping (skb); - p_fmt =MT_TX_TYPE_CT ; + p_fmt = is_usb ?MT_TX_TYPE_SF :MT_TX_TYPE_CT ; }else if (beacon) {if (ext_phy) q_idx =MT_LMAC_BCN1 ;
@@ -566,10 +567,10 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, q_idx =MT_LMAC_ALTX1 ; else q_idx =MT_LMAC_ALTX0 ; - p_fmt =MT_TX_TYPE_CT ; + p_fmt = is_usb ?MT_TX_TYPE_SF :MT_TX_TYPE_CT ; } - val =FIELD_PREP (MT_TXD0_TX_BYTES , skb->len +MT_TXD_SIZE ) | + val =FIELD_PREP (MT_TXD0_TX_BYTES , skb->len + sz_txd) |FIELD_PREP (MT_TXD0_P_IDX ,MT_TX_PORT_IDX_LMAC ) |FIELD_PREP (MT_TXD0_Q_IDX , q_idx); txwi[0 ] =cpu_to_le32 (val);
@@ -663,6 +664,9 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, txwi[7 ] =FIELD_PREP (MT_TXD7_TYPE , fc_type) |FIELD_PREP (MT_TXD7_SUB_TYPE , fc_stype); +if (is_usb) + txwi[8 ] =FIELD_PREP (MT_TXD8_L_TYPE , fc_type) | +FIELD_PREP (MT_TXD8_L_SUB_TYPE , fc_stype);return 0 ; }
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +1 -0
@@ -165,6 +165,7 @@ enum tx_phy_bandwidth {#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3)#define MT_CT_INFO_HSR2_TX BIT(4) +#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4)#define MT_TXD_SIZE (8 * 4)#define MT_TXD0_P_IDX BIT(31)
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 3/9 mt76: mt7615: introduce mt7615_mac_update_rate_desc routine
In reply to Lorenzo BianconiMove register configuration out of mt7615_mac_set_rates since usb driver can't access device register in interrupt context. Introduce mt7615_mac_update_rate_desc routine to report rate info to mt7615_mac_set_rates
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 102 ++++++++++-------- .../wireless/mediatek/mt76/mt7615/mt7615.h | 12 +++ 2 files changed, 71 insertions(+), 43 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +59 -43
@@ -811,26 +811,19 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev)rcu_read_unlock (); } -void mt7615_mac_set_rates (struct mt7615_phy *phy,struct mt7615_sta *sta, -struct ieee80211_tx_rate *probe_rate, -struct ieee80211_tx_rate *rates) +static void +mt7615_mac_update_rate_desc (struct mt7615_phy *phy,struct mt7615_sta *sta, +struct ieee80211_tx_rate *probe_rate, +struct ieee80211_tx_rate *rates, +struct mt7615_rate_desc *rd) {struct mt7615_dev *dev = phy->dev;struct mt76_phy *mphy = phy->mt76;struct ieee80211_tx_rate *ref; -int wcid = sta->wcid.idx; -u32 addr =mt7615_mac_wtbl_addr (dev, wcid); -bool stbc = false; +bool rateset, stbc = false;int n_rates = sta->n_rates; -u8 bw, bw_prev, bw_idx =0 ; -u16 val[4 ]; -u16 probe_val; -u32 w5, w27; -bool rateset; -int i, k; - -if (!mt76_poll (dev,MT_WTBL_UPDATE ,MT_WTBL_UPDATE_BUSY ,0 ,5000 )) -return ; +u8 bw, bw_prev; +int i, j;for (i = n_rates; i <4 ; i++) rates[i] = rates[n_rates -1 ];
@@ -858,10 +851,10 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,if ((ref->flags ^ rates[i].flags) &IEEE80211_TX_RC_SHORT_GI ) rates[i].flags ^=IEEE80211_TX_RC_SHORT_GI ; -for (k =0 ; k < i; k++) { -if (rates[i].idx != rates[k].idx) +for (j =0 ; j < i; j++) { +if (rates[i].idx != rates[j].idx)continue ; -if ((rates[i].flags ^ rates[k].flags) & +if ((rates[i].flags ^ rates[j].flags) & (IEEE80211_TX_RC_40_MHZ_WIDTH |IEEE80211_TX_RC_80_MHZ_WIDTH |IEEE80211_TX_RC_160_MHZ_WIDTH ))
@@ -874,65 +867,87 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, } } - val[0 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[0 ], stbc, &bw); + rd->val[0 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[0 ], stbc, &bw); bw_prev = bw;if (probe_rate) { - probe_val =mt7615_mac_tx_rate_val (dev, mphy, probe_rate, - stbc, &bw); + rd->probe_val =mt7615_mac_tx_rate_val (dev, mphy, probe_rate, + stbc, &bw);if (bw) - bw_idx =1 ; + rd->bw_idx =1 ;else bw_prev =0 ; }else { - probe_val = val[0 ]; + rd->probe_val = rd->val[0 ]; } - val[1 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[1 ], stbc, &bw); + rd->val[1 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[1 ], stbc, &bw);if (bw_prev) { - bw_idx =3 ; + rd->bw_idx =3 ; bw_prev = bw; } - val[2 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[2 ], stbc, &bw); + rd->val[2 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[2 ], stbc, &bw);if (bw_prev) { - bw_idx =5 ; + rd->bw_idx =5 ; bw_prev = bw; } - val[3 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[3 ], stbc, &bw); + rd->val[3 ] =mt7615_mac_tx_rate_val (dev, mphy, &rates[3 ], stbc, &bw);if (bw_prev) - bw_idx =7 ; + rd->bw_idx =7 ; + + rd->rateset = rateset; + rd->sta = sta; + rd->bw = bw; +} + +void mt7615_mac_set_rates (struct mt7615_phy *phy,struct mt7615_sta *sta, +struct ieee80211_tx_rate *probe_rate, +struct ieee80211_tx_rate *rates) +{ +int wcid = sta->wcid.idx, n_rates = sta->n_rates; +struct mt7615_dev *dev = phy->dev; +struct mt7615_rate_desc rd; +u32 w5, w27, addr; + +if (!mt76_poll (dev,MT_WTBL_UPDATE ,MT_WTBL_UPDATE_BUSY ,0 ,5000 )) +return ; + +memset (&rd,0 ,sizeof (struct mt7615_rate_desc )); +mt7615_mac_update_rate_desc (phy, sta, probe_rate, rates, &rd); + addr =mt7615_mac_wtbl_addr (dev, wcid); w27 =mt76_rr (dev, addr +27 *4 ); w27 &= ~MT_WTBL_W27_CC_BW_SEL ; - w27 |=FIELD_PREP (MT_WTBL_W27_CC_BW_SEL , bw); + w27 |=FIELD_PREP (MT_WTBL_W27_CC_BW_SEL , rd.bw); w5 =mt76_rr (dev, addr +5 *4 ); w5 &= ~(MT_WTBL_W5_BW_CAP |MT_WTBL_W5_CHANGE_BW_RATE |MT_WTBL_W5_MPDU_OK_COUNT |MT_WTBL_W5_MPDU_FAIL_COUNT |MT_WTBL_W5_RATE_IDX ); - w5 |=FIELD_PREP (MT_WTBL_W5_BW_CAP , bw) | -FIELD_PREP (MT_WTBL_W5_CHANGE_BW_RATE , bw_idx ? bw_idx -1 :7 ); + w5 |=FIELD_PREP (MT_WTBL_W5_BW_CAP , rd.bw) | +FIELD_PREP (MT_WTBL_W5_CHANGE_BW_RATE , + rd.bw_idx ? rd.bw_idx -1 :7 );mt76_wr (dev,MT_WTBL_RIUCR0 , w5);mt76_wr (dev,MT_WTBL_RIUCR1 , -FIELD_PREP (MT_WTBL_RIUCR1_RATE0 , probe_val) | -FIELD_PREP (MT_WTBL_RIUCR1_RATE1 , val[0 ]) | -FIELD_PREP (MT_WTBL_RIUCR1_RATE2_LO , val[1 ])); +FIELD_PREP (MT_WTBL_RIUCR1_RATE0 , rd.probe_val) | +FIELD_PREP (MT_WTBL_RIUCR1_RATE1 , rd.val[0 ]) | +FIELD_PREP (MT_WTBL_RIUCR1_RATE2_LO , rd.val[1 ]));mt76_wr (dev,MT_WTBL_RIUCR2 , -FIELD_PREP (MT_WTBL_RIUCR2_RATE2_HI , val[1 ] >>8 ) | -FIELD_PREP (MT_WTBL_RIUCR2_RATE3 , val[1 ]) | -FIELD_PREP (MT_WTBL_RIUCR2_RATE4 , val[2 ]) | -FIELD_PREP (MT_WTBL_RIUCR2_RATE5_LO , val[2 ])); +FIELD_PREP (MT_WTBL_RIUCR2_RATE2_HI , rd.val[1 ] >>8 ) | +FIELD_PREP (MT_WTBL_RIUCR2_RATE3 , rd.val[1 ]) | +FIELD_PREP (MT_WTBL_RIUCR2_RATE4 , rd.val[2 ]) | +FIELD_PREP (MT_WTBL_RIUCR2_RATE5_LO , rd.val[2 ]));mt76_wr (dev,MT_WTBL_RIUCR3 , -FIELD_PREP (MT_WTBL_RIUCR3_RATE5_HI , val[2 ] >>4 ) | -FIELD_PREP (MT_WTBL_RIUCR3_RATE6 , val[3 ]) | -FIELD_PREP (MT_WTBL_RIUCR3_RATE7 , val[3 ])); +FIELD_PREP (MT_WTBL_RIUCR3_RATE5_HI , rd.val[2 ] >>4 ) | +FIELD_PREP (MT_WTBL_RIUCR3_RATE6 , rd.val[3 ]) | +FIELD_PREP (MT_WTBL_RIUCR3_RATE7 , rd.val[3 ])); mt76_wr(dev, MT_WTBL_UPDATE, FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, wcid) |
@@ -942,7 +957,8 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,mt76_wr (dev, addr +27 *4 , w27);mt76_set (dev,MT_LPON_T0CR ,MT_LPON_T0CR_MODE );/* TSF read */ - sta->rate_set_tsf = (mt76_rr (dev,MT_LPON_UTTR0 ) & ~BIT (0 )) | rateset; + sta->rate_set_tsf =mt76_rr (dev,MT_LPON_UTTR0 ) & ~BIT (0 ); + sta->rate_set_tsf |= rd.rateset;if (!(sta->wcid.tx_info &MT_WCID_TX_INFO_SET ))mt76_poll (dev,MT_WTBL_UPDATE ,MT_WTBL_UPDATE_BUSY ,0 ,5000 );
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +12 -0
@@ -90,6 +90,18 @@ struct mt7615_rate_set {struct ieee80211_tx_rate rates[4 ]; }; +struct mt7615_rate_desc { +struct list_head node; + +struct mt7615_sta *sta; + +bool rateset; +u16 probe_val; +u16 val[4 ]; +u8 bw_idx; +u8 bw; +}; +struct mt7615_sta {struct mt76_wcid wcid;/* must be first */
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 4/9 mt76: mt7615: introduce __mt7663_load_firmware routine
In reply to Lorenzo BianconiIntroduce __mt7663_load_firmware routine to load firmware for usb devices.
--- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 22 ++++++++++++++----- .../wireless/mediatek/mt76/mt7615/mt7615.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +17 -5
@@ -2078,12 +2078,10 @@ static int mt7663_load_n9(struct mt7615_dev *dev, const char *name)return ret; } -static int mt7663_load_firmware (struct mt7615_dev *dev) +int __mt7663_load_firmware (struct mt7615_dev *dev) {int ret; -mt76_set (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_BYPASS_TX_SCH ); - ret =mt76_get_field (dev,MT_CONN_ON_MISC ,MT_TOP_MISC2_FW_N9_RDY );if (ret) {dev_dbg (dev->mt76.dev,"Firmware is already download\n" );
@@ -2109,12 +2107,26 @@ static int mt7663_load_firmware(struct mt7615_dev *dev)return -EIO ; } -mt76_clear (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_BYPASS_TX_SCH ); -dev_dbg (dev->mt76.dev,"Firmware init done\n" );return 0 ; } +EXPORT_SYMBOL_GPL (__mt7663_load_firmware); + +static int mt7663_load_firmware (struct mt7615_dev *dev) +{ +int ret; + +mt76_set (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_BYPASS_TX_SCH ); + + ret =__mt7663_load_firmware (dev); +if (ret) +return ret; + +mt76_clear (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_BYPASS_TX_SCH ); + +return 0 ; +}int mt7615_mcu_init (struct mt7615_dev *dev) {
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +1 -0
@@ -460,5 +460,6 @@ int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);int mt7615_dfs_init_radar_detector (struct mt7615_phy *phy);int mt7615_init_debugfs (struct mt7615_dev *dev); +int __mt7663_load_firmware (struct mt7615_dev *dev);#endif
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 5/9 mt76: mt7615: move mt7615_mac_wtbl_addr in mac.h
In reply to Lorenzo BianconiMove mt7615_mac_wtbl_addr in mac.h and add inline qualifier in order to be reused adding usb support to mt7615 driver
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 ----- drivers/net/wireless/mediatek/mt76/mt7615/mac.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +0 -5
@@ -721,11 +721,6 @@ void mt7615_txp_skb_unmap(struct mt76_dev *dev,mt7615_txp_skb_unmap_hw (dev, &txp->hw); } -static u32 mt7615_mac_wtbl_addr (struct mt7615_dev *dev,int wcid) -{ -return MT_WTBL_BASE (dev) + wcid *MT_WTBL_ENTRY_SIZE ; -} -bool mt7615_mac_wtbl_update (struct mt7615_dev *dev,int idx,u32 mask) { mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX,
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +5 -0
@@ -407,4 +407,9 @@ mt7615_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t) return (struct mt7615_txp_common *)(txwi + MT_TXD_SIZE); } +static inline u32 mt7615_mac_wtbl_addr (struct mt7615_dev *dev,int wcid) +{ +return MT_WTBL_BASE (dev) + wcid *MT_WTBL_ENTRY_SIZE ; +} +#endif
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 6/9 mt76: mt76u: rely on mt7622 queue scheme for mt7663u
In reply to Lorenzo BianconiRely on the mt7622 endpoint definitions for mt7663u
--- drivers/net/wireless/mediatek/mt76/usb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/usb.c +13 -2
@@ -1009,8 +1009,19 @@ static void mt76u_tx_kick(struct mt76_dev *dev, struct mt76_queue *q)static u8 mt76u_ac_to_hwq (struct mt76_dev *dev,u8 ac) { -if (mt76_chip (dev) ==0x7663 ) -return ac ^0x3 ; +if (mt76_chip (dev) ==0x7663 ) { +static const u8 wmm_queue_map[] = { + [IEEE80211_AC_VO ] =0 , + [IEEE80211_AC_VI ] =1 , + [IEEE80211_AC_BE ] =2 , + [IEEE80211_AC_BK ] =4 , + }; + +if (WARN_ON (ac >=ARRAY_SIZE (wmm_queue_map))) +return 2 ;/* BE */ + +return wmm_queue_map[ac]; + }return mt76_ac_to_hwq (ac); }
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 7/9 mt76: mt7615: rework wtbl key configuration
In reply to Lorenzo BianconiRemove key dependency from mt7615_mac_wtbl_update_key and export mt7615_mac_wtbl_update_key, mt7615_mac_wtbl_update_pk and mt7615_mac_wtbl_update_cipher in order to reuse them in usb code. Move mt7615_mac_get_cipher in mac.h
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 69 +++++++------------ .../net/wireless/mediatek/mt76/mt7615/mac.h | 27 ++++++++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 14 ++++ 3 files changed, 64 insertions(+), 46 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +23 -46
@@ -962,58 +962,31 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, sta->wcid.tx_info |=MT_WCID_TX_INFO_SET ; } -static enum mt7615_cipher_type -mt7615_mac_get_cipher (int cipher) -{ -switch (cipher) { -case WLAN_CIPHER_SUITE_WEP40 : -return MT_CIPHER_WEP40 ; -case WLAN_CIPHER_SUITE_WEP104 : -return MT_CIPHER_WEP104 ; -case WLAN_CIPHER_SUITE_TKIP : -return MT_CIPHER_TKIP ; -case WLAN_CIPHER_SUITE_AES_CMAC : -return MT_CIPHER_BIP_CMAC_128 ; -case WLAN_CIPHER_SUITE_CCMP : -return MT_CIPHER_AES_CCMP ; -case WLAN_CIPHER_SUITE_CCMP_256 : -return MT_CIPHER_CCMP_256 ; -case WLAN_CIPHER_SUITE_GCMP : -return MT_CIPHER_GCMP ; -case WLAN_CIPHER_SUITE_GCMP_256 : -return MT_CIPHER_GCMP_256 ; -case WLAN_CIPHER_SUITE_SMS4 : -return MT_CIPHER_WAPI ; -default : -return MT_CIPHER_NONE ; - } -} - -static int -mt7615_mac_wtbl_update_key (struct mt7615_dev *dev,struct mt76_wcid *wcid, -struct ieee80211_key_conf *key, -enum mt7615_cipher_type cipher, -enum set_key_cmd cmd) +int mt7615_mac_wtbl_update_key (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +u8 *key,u8 keylen, +enum mt7615_cipher_type cipher, +enum set_key_cmd cmd) {u32 addr =mt7615_mac_wtbl_addr (dev, wcid->idx) +30 *4 ;u8 data[32 ] = {}; -if (key->keylen >sizeof (data)) +if (keylen >sizeof (data))return -EINVAL ;mt76_rr_copy (dev, addr, data,sizeof (data));if (cmd ==SET_KEY ) {if (cipher ==MT_CIPHER_TKIP ) {/* Rx/Tx MIC keys are swapped */ -memcpy (data +16 , key->key +24 ,8 ); -memcpy (data +24 , key->key +16 ,8 ); +memcpy (data +16 , key +24 ,8 ); +memcpy (data +24 , key +16 ,8 ); }if (cipher !=MT_CIPHER_BIP_CMAC_128 && wcid->cipher)memmove (data +16 , data,16 );if (cipher !=MT_CIPHER_BIP_CMAC_128 || !wcid->cipher) -memcpy (data, key->key, key->keylen); +memcpy (data, key, keylen);else if (cipher ==MT_CIPHER_BIP_CMAC_128 ) -memcpy (data +16 , key->key,16 ); +memcpy (data +16 , key,16 ); }else {if (wcid->cipher & ~BIT (cipher)) {if (cipher !=MT_CIPHER_BIP_CMAC_128 )
@@ -1027,11 +1000,12 @@ mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,return 0 ; } +EXPORT_SYMBOL_GPL (mt7615_mac_wtbl_update_key); -static int -mt7615_mac_wtbl_update_pk (struct mt7615_dev *dev,struct mt76_wcid *wcid, -enum mt7615_cipher_type cipher,int keyidx, -enum set_key_cmd cmd) +int mt7615_mac_wtbl_update_pk (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +enum mt7615_cipher_type cipher, +int keyidx,enum set_key_cmd cmd) {u32 addr =mt7615_mac_wtbl_addr (dev, wcid->idx), w0, w1;
@@ -1063,11 +1037,12 @@ mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid,return 0 ; } +EXPORT_SYMBOL_GPL (mt7615_mac_wtbl_update_pk); -static void -mt7615_mac_wtbl_update_cipher (struct mt7615_dev *dev,struct mt76_wcid *wcid, -enum mt7615_cipher_type cipher, -enum set_key_cmd cmd) +void mt7615_mac_wtbl_update_cipher (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +enum mt7615_cipher_type cipher, +enum set_key_cmd cmd) {u32 addr =mt7615_mac_wtbl_addr (dev, wcid->idx);
@@ -1085,6 +1060,7 @@ mt7615_mac_wtbl_update_cipher(struct mt7615_dev *dev, struct mt76_wcid *wcid,mt76_clear (dev, addr +2 *4 ,MT_WTBL_W2_KEY_TYPE ); } } +EXPORT_SYMBOL_GPL (mt7615_mac_wtbl_update_cipher); int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
@@ -1101,7 +1077,8 @@ int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev,spin_lock_bh (&dev->mt76.lock);mt7615_mac_wtbl_update_cipher (dev, wcid, cipher, cmd); - err =mt7615_mac_wtbl_update_key (dev, wcid, key, cipher, cmd); + err =mt7615_mac_wtbl_update_key (dev, wcid, key->key, key->keylen, + cipher, cmd);if (err <0 ) goto out;
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +27 -0
@@ -394,6 +394,33 @@ enum mt7615_cipher_type { MT_CIPHER_GCMP_256, }; +static inline enum mt7615_cipher_type +mt7615_mac_get_cipher (int cipher) +{ +switch (cipher) { +case WLAN_CIPHER_SUITE_WEP40 : +return MT_CIPHER_WEP40 ; +case WLAN_CIPHER_SUITE_WEP104 : +return MT_CIPHER_WEP104 ; +case WLAN_CIPHER_SUITE_TKIP : +return MT_CIPHER_TKIP ; +case WLAN_CIPHER_SUITE_AES_CMAC : +return MT_CIPHER_BIP_CMAC_128 ; +case WLAN_CIPHER_SUITE_CCMP : +return MT_CIPHER_AES_CCMP ; +case WLAN_CIPHER_SUITE_CCMP_256 : +return MT_CIPHER_CCMP_256 ; +case WLAN_CIPHER_SUITE_GCMP : +return MT_CIPHER_GCMP ; +case WLAN_CIPHER_SUITE_GCMP_256 : +return MT_CIPHER_GCMP_256 ; +case WLAN_CIPHER_SUITE_SMS4 : +return MT_CIPHER_WAPI ; +default : +return MT_CIPHER_NONE ; + } +} +static inline struct mt7615_txp_common *mt7615_txwi_to_txp (struct mt76_dev *dev,struct mt76_txwi_cache *t) {
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +14 -0
@@ -67,6 +67,7 @@ struct mt7615_vif;struct mt7615_sta ;struct mt7615_dfs_pulse ;struct mt7615_dfs_pattern ; +enum mt7615_cipher_type ;enum mt7615_hw_txq_id {MT7615_TXQ_MAIN ,
@@ -410,6 +411,19 @@ void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb);int mt7615_mac_wtbl_set_key (struct mt7615_dev *dev,struct mt76_wcid *wcid,struct ieee80211_key_conf *key,enum set_key_cmd cmd); +int mt7615_mac_wtbl_update_pk (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +enum mt7615_cipher_type cipher, +int keyidx,enum set_key_cmd cmd); +void mt7615_mac_wtbl_update_cipher (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +enum mt7615_cipher_type cipher, +enum set_key_cmd cmd); +int mt7615_mac_wtbl_update_key (struct mt7615_dev *dev, +struct mt76_wcid *wcid, +u8 *key,u8 keylen, +enum mt7615_cipher_type cipher, +enum set_key_cmd cmd);void mt7615_mac_reset_work (struct work_struct *work);int mt7615_mcu_wait_response (struct mt7615_dev *dev,int cmd,int seq);
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 8/9 mt76: mt7615: introduce mt7615_wtbl_desc data structure
In reply to Lorenzo BianconiGeneralize mt7615_rate_desc introducing mt7615_wtbl_desc and mt7615_key_desc data structures in order to configure the hw wtbl in a non-atomic context for usb devices
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 1 - .../wireless/mediatek/mt76/mt7615/mt7615.h | 29 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +0 -1
@@ -893,7 +893,6 @@ mt7615_mac_update_rate_desc(struct mt7615_phy *phy, struct mt7615_sta *sta, rd->bw_idx =7 ; rd->rateset = rateset; - rd->sta = sta; rd->bw = bw; }
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +25 -4
@@ -92,10 +92,6 @@ struct mt7615_rate_set { };struct mt7615_rate_desc { -struct list_head node; - -struct mt7615_sta *sta; -bool rateset;u16 probe_val;u16 val[4 ];
@@ -103,6 +99,31 @@ struct mt7615_rate_desc {u8 bw; }; +enum mt7615_wtbl_desc_type { +MT7615_WTBL_RATE_DESC , +MT7615_WTBL_KEY_DESC +}; + +struct mt7615_key_desc { +enum set_key_cmd cmd; +u32 cipher; +s8 keyidx; +u8 keylen; +u8 *key; +}; + +struct mt7615_wtbl_desc { +struct list_head node; + +enum mt7615_wtbl_desc_type type; +struct mt7615_sta *sta; + +union { +struct mt7615_rate_desc rate; +struct mt7615_key_desc key; + }; +}; +struct mt7615_sta {struct mt76_wcid wcid;/* must be first */
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerPATCH 9/9 mt76: mt7615: add address parameter to mt7615_eeprom_init
In reply to Lorenzo BianconiIntroduce address parameter to mt7615_eeprom_init routine in order to be reused adding usb support to mt7615 driver
--- drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c | 12 ++++++------ drivers/net/wireless/mediatek/mt76/mt7615/init.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c +6 -6
@@ -40,11 +40,11 @@ static int mt7615_efuse_read(struct mt7615_dev *dev, u32 base,return 0 ; } -static int mt7615_efuse_init (struct mt7615_dev *dev) +static int mt7615_efuse_init (struct mt7615_dev *dev,u32 base) { -u32 val, base =mt7615_reg_map (dev,MT_EFUSE_BASE );int i, len =MT7615_EEPROM_SIZE ;void *buf; +u32 val; val =mt76_rr (dev, base +MT_EFUSE_BASE_CTRL );if (val &MT_EFUSE_BASE_CTRL_EMPTY )
@@ -67,7 +67,7 @@ static int mt7615_efuse_init(struct mt7615_dev *dev)return 0 ; } -static int mt7615_eeprom_load (struct mt7615_dev *dev) +static int mt7615_eeprom_load (struct mt7615_dev *dev,u32 addr) {int ret;
@@ -75,7 +75,7 @@ static int mt7615_eeprom_load(struct mt7615_dev *dev)if (ret <0 )return ret; -return mt7615_efuse_init (dev); +return mt7615_efuse_init (dev, addr); }static int mt7615_check_eeprom (struct mt76_dev *dev)
@@ -265,11 +265,11 @@ static void mt7615_cal_free_data(struct mt7615_dev *dev) } } -int mt7615_eeprom_init (struct mt7615_dev *dev) +int mt7615_eeprom_init (struct mt7615_dev *dev,u32 addr) {int ret; - ret =mt7615_eeprom_load (dev); + ret =mt7615_eeprom_load (dev, addr);if (ret <0 )return ret;
drivers/net/wireless/mediatek/mt76/mt7615/init.c +2 -1
@@ -146,6 +146,7 @@ static void mt7615_init_work(struct work_struct *work)static int mt7615_init_hardware (struct mt7615_dev *dev) { +u32 addr =mt7615_reg_map (dev,MT_EFUSE_BASE );int ret, idx;mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );
@@ -154,7 +155,7 @@ static int mt7615_init_hardware(struct mt7615_dev *dev)spin_lock_init (&dev->token_lock);idr_init (&dev->token); - ret =mt7615_eeprom_init (dev); + ret =mt7615_eeprom_init (dev, addr);if (ret <0 )return ret;
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +1 -1
@@ -358,7 +358,7 @@ int mt7615_register_device(struct mt7615_dev *dev);void mt7615_unregister_device (struct mt7615_dev *dev);int mt7615_register_ext_phy (struct mt7615_dev *dev);void mt7615_unregister_ext_phy (struct mt7615_dev *dev); -int mt7615_eeprom_init (struct mt7615_dev *dev); +int mt7615_eeprom_init (struct mt7615_dev *dev,u32 addr);int mt7615_eeprom_get_power_index (struct mt7615_dev *dev,struct ieee80211_channel *chan,u8 chain_idx);
Signature · 1 line
2.25.1