qtnfmac: qsr10g pcie backend updates
v2 cover qtnfmac: qsr10g pcie backend updates
Hello Kalle and all,
Here is a patch set with various fixes and enhacements for qsr10g PCIe backend driver. The major changes include the following two items:
- make rmmod/insmod work properly for qtnfmac_pcie driver
- provide configuration knobs to control NSM (networked standby mode)
NSM (networked standby mode) is not related to WiFi standard. This is a term that has been introduced by European Commission in regulation No. 1275/2008. Simplifying things a bit, that regulation specifies ecodesing requirements for various operating modes. In that document ‘networked standby’ is defined as a condition in which the equipment is able to resume a function by way of a remotely initiated trigger from a network connection.
Regards,
Sergey
Changes v1 -> v2
- do not perform fw check using request_firmware (Arend)
- meld rmmod/insmod fixes into async fw async load patch -- those fixes are reworked by that patch anyway
Sergei Maksimenko (3)
qtnfmac: implement asynchronous firmware loading
qtnfmac: enable reloading of qtnfmac kernel modules
qtnfmac: enable networked standby mode on device
Sergey Matyukevich (1)
qtnfmac: fix releasing Tx/Rx data buffers
bus.h | 4 commands.c | 33 +++ commands.h | 1 core.c | 77 ++++++++ core.h | 2 pearl/pcie.c | 418 ++++++++++++++++++++++++------------------------ pearl/pcie_ipc.h | 1 pearl/pcie_regs_pearl.h | 1 qlink.h | 30 +++ 9 files changed, 357 insertions(+), 210 deletions(-)
PATCH v2 1/4 qtnfmac: fix releasing Tx/Rx data buffers
Add missing PCI unmap for Tx buffers and release all buffers explicitly. Managed release using devm_add_action is not suitable for qtnfmac Tx/Rx data buffers. The reason is in ordering and dependencies: buffers should be released after transmission is stopped but before PCI device resources and DMA allocations are released.
--- .../net/wireless/quantenna/qtnfmac/pearl/pcie.c | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +18 -12
@@ -478,10 +478,11 @@ static int alloc_rx_buffers(struct qtnf_pcie_bus_priv *priv) }/* all rx/tx activity should have ceased before calling this function */ -static void free_xfer_buffers (void *data) +static void qtnf_free_xfer_buffers (struct qtnf_pcie_bus_priv *priv) { -struct qtnf_pcie_bus_priv *priv = (struct qtnf_pcie_bus_priv *)data; +struct qtnf_tx_bd *txbd;struct qtnf_rx_bd *rxbd; +struct sk_buff *skb;dma_addr_t paddr;int i;
@@ -489,19 +490,26 @@ static void free_xfer_buffers(void *data)for (i =0 ; i < priv->rx_bd_num; i++) {if (priv->rx_skb && priv->rx_skb[i]) { rxbd = &priv->rx_bd_vbase[i]; + skb = priv->rx_skb[i]; paddr =QTN_HOST_ADDR (le32_to_cpu (rxbd->addr_h),le32_to_cpu (rxbd->addr));pci_unmap_single (priv->pdev, paddr,SKB_BUF_SIZE ,PCI_DMA_FROMDEVICE ); - -dev_kfree_skb_any (priv->rx_skb[i]); +dev_kfree_skb_any (skb); + priv->rx_skb[i] =NULL ; } }/* free tx buffers */ for (i =0 ; i < priv->tx_bd_num; i++) {if (priv->tx_skb && priv->tx_skb[i]) { -dev_kfree_skb_any (priv->tx_skb[i]); + txbd = &priv->tx_bd_vbase[i]; + skb = priv->tx_skb[i]; + paddr =QTN_HOST_ADDR (le32_to_cpu (txbd->addr_h), +le32_to_cpu (txbd->addr)); +pci_unmap_single (priv->pdev, paddr, skb->len, +PCI_DMA_TODEVICE ); +dev_kfree_skb_any (skb); priv->tx_skb[i] =NULL ; } }
@@ -1321,12 +1329,6 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } - ret =devm_add_action (&pdev->dev, free_xfer_buffers, (void *)pcie_priv); -if (ret) { -pr_err ("custom release callback init failed\n" ); - goto err_base; - } - ret =qtnf_pcie_init_xfer (pcie_priv);if (ret) {pr_err ("PCIE xfer init failed\n" );
@@ -1343,7 +1345,7 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) "qtnf_pcie_irq", (void *)bus);if (ret) {pr_err ("failed to request pcie irq %d\n" , pdev->irq); - goto err_base; + goto err_xfer; } tasklet_init(&pcie_priv->reclaim_tq, qtnf_reclaim_tasklet_fn,
@@ -1387,6 +1389,9 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_bringup_fw:netif_napi_del (&bus->mux_napi); +err_xfer: +qtnf_free_xfer_buffers (pcie_priv); + err_base:flush_workqueue (pcie_priv->workqueue);destroy_workqueue (pcie_priv->workqueue);
@@ -1416,6 +1421,7 @@ static void qtnf_pcie_remove(struct pci_dev *pdev)destroy_workqueue (priv->workqueue);tasklet_kill (&priv->reclaim_tq); +qtnf_free_xfer_buffers (priv);qtnf_debugfs_remove (bus);qtnf_pcie_free_shm_ipc (priv);
Signature · 1 line
2.11.0
Re: [v2,1/4] qtnfmac: fix releasing Tx/Rx data buffers
Quoted 7 lines · Sergey Matyukevich
Add missing PCI unmap for Tx buffers and release all buffers explicitly. Managed release using
devm_add_actionis not suitable for qtnfmac Tx/Rx data buffers. The reason is in ordering and dependencies: buffers should be released after transmission is stopped but before PCI device resources and DMA allocations are released.Signed-off-by Sergey Matyukevich <[email protected]>
3 patches applied to wireless-drivers-next.git, thanks.
1d5e3b90ab01 qtnfmac: fix releasing Tx/Rx data buffers a34d7bcb73f5 qtnfmac: enable reloading of qtnfmac kernel modules c3b2f7ca4186 qtnfmac: implement asynchronous firmware loading
Signature · 3 lines
https://patchwork.kernel.org/patch/10210499/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH v2 2/4 qtnfmac: enable reloading of qtnfmac kernel modules
In reply to Sergey MatyukevichFrom: Sergei Maksimenko <[email protected]>
This patch enables rmmod/insmod for qtnfmac kernel modules:
- do not 'pin' pci device in order to disable it on module unload
- implement card reset procedure
- restore PCI bar addresses for restarted wireless card
--- drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 15 ++++++++++++++- drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h | 1 + .../wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +14 -1
@@ -162,6 +162,17 @@ static void qtnf_deassert_intx(struct qtnf_pcie_bus_priv *priv)qtnf_non_posted_write (cfg, reg); } +static void qtnf_reset_card (struct qtnf_pcie_bus_priv *priv) +{ +const u32 data =QTN_PEARL_IPC_IRQ_WORD (QTN_PEARL_LHOST_EP_RESET ); +void __iomem *reg = priv->sysctl_bar + +QTN_PEARL_SYSCTL_LHOST_IRQ_OFFSET ; + +qtnf_non_posted_write (data, reg); +msleep (QTN_EP_RESET_WAIT_MS ); +pci_restore_state (priv->pdev); +} +static void qtnf_ipc_gen_ep_int (void *arg) {const struct qtnf_pcie_bus_priv *priv = arg;
@@ -1308,7 +1319,6 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } -pcim_pin_device (pdev);pci_set_master (pdev); ret =qtnf_pcie_init_irq (pcie_priv);
@@ -1323,6 +1333,8 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } +pci_save_state (pdev); + ret =qtnf_pcie_init_shm_ipc (pcie_priv);if (ret <0 ) {pr_err ("PCIE SHM IPC init failed\n" );
@@ -1425,6 +1437,7 @@ static void qtnf_pcie_remove(struct pci_dev *pdev)qtnf_debugfs_remove (bus);qtnf_pcie_free_shm_ipc (priv); +qtnf_reset_card (priv); }#ifdef CONFIG_PM_SLEEP
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h +1 -0
@@ -46,6 +46,7 @@/* state transition timeouts */ #define QTN_FW_DL_TIMEOUT_MS 3000#define QTN_FW_QLINK_TIMEOUT_MS 30000 +#define QTN_EP_RESET_WAIT_MS 1000#define PCIE_HDP_INT_RX_BITS (0 \ | PCIE_HDP_INT_EP_TXDMA \
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h +1 -0
@@ -351,5 +351,6 @@#define QTN_PEARL_IPC_IRQ_WORD (irq) (BIT(irq) | BIT(irq + 16))#define QTN_PEARL_LHOST_IPC_IRQ (6) +#define QTN_PEARL_LHOST_EP_RESET (7)#endif /* __PEARL_PCIE_H */
Signature · 1 line
2.11.0
PATCH v2 3/4 qtnfmac: implement asynchronous firmware loading
In reply to Sergey MatyukevichIn pci probe() function start firmware loading, protocol handshake and driver core initialization, and not wait for completion.
--- drivers/net/wireless/quantenna/qtnfmac/bus.h | 3 +- .../net/wireless/quantenna/qtnfmac/pearl/pcie.c | 375 ++++++++++----------- 2 files changed, 180 insertions(+), 198 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/bus.h +2 -1
@@ -59,8 +59,9 @@ struct qtnf_bus {char fwname[32 ];struct napi_struct mux_napi;struct net_device mux_dev; -struct completion request_firmware_complete; +struct completion firmware_init_complete;struct workqueue_struct *workqueue; +struct work_struct fw_work;struct work_struct event_work;struct mutex bus_lock;/* lock during command/event processing */ struct dentry *dbg_dir;
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +178 -197
496 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 4/4 qtnfmac: enable networked standby mode on device inactivity
In reply to Sergey MatyukevichFrom: Sergei Maksimenko <[email protected]>
Enable support of networked standby mode (NSM) on qsr10g devices. Networked standby is a power saving mode when the device keeps all existing network connections and returns to full power mode on a network activity. When enabled, device enters standby mode after 15 min of inactivity (no associated stations or no trattic). This period can be changed by setting sysfs attribute standby_timeout (0 disables NSM support). A module parameter auto_standby (defaults to 1) controls enabling NSM support on module loading.
--- drivers/net/wireless/quantenna/qtnfmac/bus.h | 1 + drivers/net/wireless/quantenna/qtnfmac/commands.c | 33 ++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 1 + drivers/net/wireless/quantenna/qtnfmac/core.c | 77 +++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/core.h | 2 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 30 +++++++++ 6 files changed, 144 insertions(+)
drivers/net/wireless/quantenna/qtnfmac/bus.h +1 -0
@@ -65,6 +65,7 @@ struct qtnf_bus {struct work_struct event_work;struct mutex bus_lock;/* lock during command/event processing */ struct dentry *dbg_dir; +u32 standby_timeout;/* bus private data */ char bus_priv[0 ]__aligned(sizeof(void *)) ; };
drivers/net/wireless/quantenna/qtnfmac/commands.c +33 -0
@@ -2753,3 +2753,36 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,return ret; } + +int qtnf_cmd_send_pm_set (struct qtnf_bus *bus,u8 pm_mode,u32 timeout) +{ +struct sk_buff *cmd_skb; +u16 res_code =QLINK_CMD_RESULT_OK ; +struct qlink_cmd_pm_set *cmd; +int ret =0 ; + + cmd_skb =qtnf_cmd_alloc_new_cmdskb (QLINK_MACID_RSVD ,QLINK_VIFID_RSVD , +QLINK_CMD_PM_SET ,sizeof (*cmd)); +if (!cmd_skb) +return -ENOMEM ; + + cmd = (struct qlink_cmd_pm_set *)cmd_skb->data; + cmd->pm_mode = pm_mode; + cmd->pm_standby_timer =cpu_to_le32 (timeout); + +qtnf_bus_lock (bus); + + ret =qtnf_cmd_send (bus, cmd_skb, &res_code); + +if (unlikely (ret)) + goto out; + +if (unlikely (res_code !=QLINK_CMD_RESULT_OK )) { +pr_err ("cmd exec failed: 0x%.4X\n" , res_code); + ret = -EFAULT ; + } + +out: +qtnf_bus_unlock (bus); +return ret; +}
drivers/net/wireless/quantenna/qtnfmac/commands.h +1 -0
@@ -81,5 +81,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, u32 cac_time_ms);int qtnf_cmd_set_mac_acl (const struct qtnf_vif *vif,const struct cfg80211_acl_data *params); +int qtnf_cmd_send_pm_set (struct qtnf_bus *bus,u8 pm_mode,u32 timeout);#endif /* QLINK_COMMANDS_H_ */
drivers/net/wireless/quantenna/qtnfmac/core.c +77 -0
101 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/core.h +2 -0
@@ -52,6 +52,8 @@#define QTNF_DEF_WDOG_TIMEOUT 5#define QTNF_TX_TIMEOUT_TRSHLD 100 +#define QTNF_DEFAULT_STANDBY_TIMER (15 * 60) +extern const struct net_device_ops qtnf_netdev_ops;struct qtnf_bus ;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +30 -0
@@ -251,6 +251,7 @@ enum qlink_cmd_type {QLINK_CMD_CHAN_STATS =0x0054 ,QLINK_CMD_CONNECT =0x0060 ,QLINK_CMD_DISCONNECT =0x0061 , + QLINK_CMD_PM_SET = 0x0062, };/**
@@ -663,6 +664,35 @@ struct qlink_acl_data {struct qlink_mac_address mac_addrs[0 ]; } __packed; +/** +* enum qlink_pm_mode - Power Management mode +* +* @QLINK_PM_OFF: normal mode, no power saving enabled +* @QLINK_PM_AUTO_STANDBY: Automatic Network Standby Mode - when there is no +* traffic for the certain period, device enters power saving mode without +* disconnecting peers. Device will wake up automatically on a new +* association or data frames to TX/RX. Standby mode is activated on each +* radio interface individually, based on traffic on it. When all the +* radios enter standby mode, device informs RC via MSI. +*/ +enum qlink_pm_mode { +QLINK_PM_OFF =0 , +QLINK_PM_AUTO_STANDBY =1 , +}; + +/** +* struct qlink_cmd_pm_set - data for QLINK_CMD_PM_SET command +* +* @pm_standby timer: period of network inactivity in seconds before +* putting a radio in standby mode +* @pm_mode: power management mode +*/ +struct qlink_cmd_pm_set { +struct qlink_cmd chdr; +__le32 pm_standby_timer; +u8 pm_mode; +} __packed; +/* QLINK Command Responses messages related definitions */
Signature · 1 line
2.11.0
Re: [PATCH v2 4/4] qtnfmac: enable networked standby mode on device inactivity
Quoted 11 lines · Sergey Matyukevich
From: Sergei Maksimenko <[email protected]>
Enable support of networked standby mode (NSM) on qsr10g devices. Networked standby is a power saving mode when the device keeps all existing network connections and returns to full power mode on a network activity. When enabled, device enters standby mode after 15 min of inactivity (no associated stations or no trattic). This period can be changed by setting sysfs attribute
standby_timeout(0 disables NSM support). A module parameterauto_standby(defaults to 1) controls enabling NSM support on module loading.
Quoted 1 line
Signed-off-by Sergei Maksimenko <[email protected]>
Adding a new sysfs file for a wireless driver is usually a bad idea, I don't even remember when we had a case where it was ok to do that. In principle we want everything to go through cfg80211 using nl80211.
Also I'm not really fond of the module parameter just to disable a feature. And there isn't even any justification why it's needed.
Signature · 1 line
Kalle Valo
Re: [PATCH v2 4/4] qtnfmac: enable networked standby mode on device inactivity
Quoted 13 lines
Quoted 11 lines · Sergey Matyukevich
From: Sergei Maksimenko <[email protected]>
Enable support of networked standby mode (NSM) on qsr10g devices. Networked standby is a power saving mode when the device keeps all existing network connections and returns to full power mode on a network activity. When enabled, device enters standby mode after 15 min of inactivity (no associated stations or no trattic). This period can be changed by setting sysfs attribute
standby_timeout(0 disables NSM support). A module parameterauto_standby(defaults to 1) controls enabling NSM support on module loading.
Quoted 8 lines
Quoted 1 line
Signed-off-by Sergei Maksimenko <[email protected]>Adding a new sysfs file for a wireless driver is usually a bad idea, I don't even remember when we had a case where it was ok to do that. In principle we want everything to go through cfg80211 using nl80211.
Also I'm not really fond of the module parameter just to disable a feature. And there isn't even any justification why it's needed.
Ok, noted. Then we will take a break and look for better ways to integrate this feature. Meanwhile, if you have no concerns regarding the first three patches in the series, is it possible to apply them ? Or I better send v3 ?
Regards,
Sergey
Re: [PATCH v2 4/4] qtnfmac: enable networked standby mode on device inactivity
Quoted 19 lines · Sergey Matyukevich
Quoted 19 lines
Quoted 11 lines · Sergey Matyukevich
From: Sergei Maksimenko <[email protected]>
Enable support of networked standby mode (NSM) on qsr10g devices. Networked standby is a power saving mode when the device keeps all existing network connections and returns to full power mode on a network activity. When enabled, device enters standby mode after 15 min of inactivity (no associated stations or no trattic). This period can be changed by setting sysfs attribute
standby_timeout(0 disables NSM support). A module parameterauto_standby(defaults to 1) controls enabling NSM support on module loading.Quoted 1 line
Signed-off-by Sergei Maksimenko <[email protected]>Adding a new sysfs file for a wireless driver is usually a bad idea, I don't even remember when we had a case where it was ok to do that. In principle we want everything to go through cfg80211 using nl80211.
Quoted 6 lines
Quoted 2 lines
Also I'm not really fond of the module parameter just to disable a feature. And there isn't even any justification why it's needed.
Ok, noted. Then we will take a break and look for better ways to integrate this feature. Meanwhile, if you have no concerns regarding the first three patches in the series, is it possible to apply them ? Or I better send v3 ?
Yeah, patches 1-3 are on my queue and I should apply them soon.
Signature · 1 line
Kalle Valo