mt_wifi: fix wext txpwr api panic with apcli

This commit is contained in:
hanwckf 2023-12-02 22:05:52 +08:00
parent 3496679e0c
commit 68689844be

View File

@ -1,6 +1,6 @@
--- a/mt_wifi/embedded/ap/ap_cfg.c
+++ b/mt_wifi/embedded/ap/ap_cfg.c
@@ -29235,6 +29235,41 @@ INT32 rtmp_get_macPower(IN VOID *pAdSrc)
@@ -29235,6 +29235,46 @@ INT32 rtmp_get_macPower(IN VOID *pAdSrc)
return retPwr;
}
@ -22,21 +22,26 @@
+ MTWF_DBG(NULL, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_ERROR, "pObj null!\n");
+ return -EFAULT;
+ }
+ apidx = pObj->ioctl_if;
+ /* For all ioctl to this function, we assume that's query for AP/APCLI/GO device */
+ if ((pObj->ioctl_if_type == INT_MBSSID) || (pObj->ioctl_if_type == INT_MAIN)) {
+
+ if ((pObj->ioctl_if_type == INT_MBSSID) || (pObj->ioctl_if_type == INT_MAIN))
+ {
+ apidx = pObj->ioctl_if;
+ if (apidx >= ad->ApCfg.BssidNum)
+ return -EFAULT;
+
+ wdev = &ad->ApCfg.MBSSID[apidx].wdev;
+
+ if (wdev)
+ BandIdx = HcGetBandByWdev(wdev);
+ else
+ BandIdx = BAND0;
+
+ Tx_Pwr = (ad->ApCfg.MgmtTxPwr[BandIdx] + ad->ApCfg.EpaFeGain[BandIdx] + (wdev->TxPwrDelta)) / 2;
+
+ return Tx_Pwr;
+ }
+ if (wdev)
+ BandIdx = HcGetBandByWdev(wdev);
+ else
+ BandIdx = BAND0;
+
+ Tx_Pwr = (ad->ApCfg.MgmtTxPwr[BandIdx] + ad->ApCfg.EpaFeGain[BandIdx] + (wdev->TxPwrDelta)) / 2;
+
+ return Tx_Pwr;
+ return -EFAULT;
+}
+
#ifdef CONFIG_6G_SUPPORT
@ -53,17 +58,39 @@
INT rt28xx_ap_ioctl(void *net_dev_obj, void *data_obj, int cmd) /* snowpin for ap/sta */
{
struct net_device *net_dev;
@@ -803,11 +805,11 @@ INT rt28xx_ap_ioctl(void *net_dev_obj, v
@@ -801,18 +803,24 @@ INT rt28xx_ap_ioctl(void *net_dev_obj, v
{
INT32 powerval = 0;
wdev = pIoctlConfig->wdev;
if (wdev->if_up_down_state == FALSE) {
- wdev = pIoctlConfig->wdev;
- if (wdev->if_up_down_state == FALSE) {
- MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
+ MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_INFO,
"RT_PRIV_IOCTL interface is down, cmd [%x] return!!!\n", cmd);
return -ENETDOWN;
- "RT_PRIV_IOCTL interface is down, cmd [%x] return!!!\n", cmd);
- return -ENETDOWN;
+ if (RT_DEV_PRIV_FLAGS_GET(net_dev) == INT_MAIN ||
+ RT_DEV_PRIV_FLAGS_GET(net_dev) == INT_MBSSID) {
+ wdev = pIoctlConfig->wdev;
+ if (wdev->if_up_down_state == FALSE) {
+ MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_INFO,
+ "RT_PRIV_IOCTL interface is down, cmd [%x] return!!!\n", cmd);
+ return -ENETDOWN;
+ }
+ powerval = rtmp_get_mgmtpwr(pAd);
+ MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_INFO, "power = %d\n", powerval);
+ wrqin->u.txpower.value = powerval;/* The value of the parameter itself */
+ wrqin->u.txpower.disabled = 0;/* Disable the feature */
+ wrqin->u.txpower.flags = 0;/* dBm */
+ wrqin->u.txpower.fixed = 0;/* Hardware should not use auto select */
+ } else {
+ Status = RTMP_IO_EOPNOTSUPP;
}
- powerval = rtmp_get_macPower(pAd);
+ powerval = rtmp_get_mgmtpwr(pAd);
MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_INFO, "power = %d\n", powerval);
wrqin->u.txpower.value = powerval;/* The value of the parameter itself */
wrqin->u.txpower.disabled = 0;/* Disable the feature */
- MTWF_DBG(pAd, DBG_CAT_CFG, DBG_SUBCAT_ALL, DBG_LVL_INFO, "power = %d\n", powerval);
- wrqin->u.txpower.value = powerval;/* The value of the parameter itself */
- wrqin->u.txpower.disabled = 0;/* Disable the feature */
- wrqin->u.txpower.flags = 0;/* dBm */
- wrqin->u.txpower.fixed = 0;/* Hardware should not use auto select */
+
break;
}
case SIOCGIWRANGE: /*Get range of parameters */