Parcourir la source

qcacld-3.0: [11AX] Add support to configure peer rate

Add support for to configure peer rates using set_peer_rate
iwpriv command.

Change-Id: I5181686a155fb7212cbcb89168b1929e00b0d1d1
CRs-Fixed: 1073481
Krishna Kumaar Natarajan il y a 8 ans
Parent
commit
f1581df779

+ 1 - 0
core/hdd/inc/qc_sap_ioctl.h

@@ -256,6 +256,7 @@ enum {
 	QCSAP_PARAM_CHAN_WIDTH,
 	QCSAP_PARAM_SET_TXRX_STATS,
 	QCASAP_SET_11AX_RATE,
+	QCASAP_SET_PEER_RATE,
 };
 
 int iw_get_channel_list(struct net_device *dev,

+ 9 - 0
core/hdd/inc/wlan_hdd_wext.h

@@ -411,6 +411,15 @@ int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate);
 int hdd_set_11ax_rate(hdd_adapter_t *adapter, int value,
 		      struct sap_Config *sap_config);
 
+/**
+ * hdd_set_peer_rate() - set peer rate
+ * @adapter: adapter being modified
+ * @value: rate code with AID
+ *
+ * Return: 0 on success, negative errno on failure
+ */
+int hdd_set_peer_rate(hdd_adapter_t *adapter, int value);
+
 void wlan_hdd_change_country_code_callback(void *pAdapter);
 
 int hdd_set_band(struct net_device *dev, u8 ui_band);

+ 9 - 0
core/hdd/src/wlan_hdd_hostapd.c

@@ -3306,6 +3306,9 @@ static __iw_softap_setparam(struct net_device *dev,
 					&pHostapdAdapter->sessionCtx.ap.
 					sapConfig);
 		break;
+	case QCASAP_SET_PEER_RATE:
+		ret = hdd_set_peer_rate(pHostapdAdapter, set_value);
+		break;
 	default:
 		hdd_err("Invalid setparam command %d value %d",
 		       sub_cmd, set_value);
@@ -5772,6 +5775,12 @@ static const struct iw_priv_args hostapd_private_args[] = {
 		0, "set_11ax_rate"
 	}
 	,
+	{
+		QCASAP_SET_PEER_RATE,
+		IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+		0, "set_peer_rate"
+	}
+	,
 };
 
 static const iw_handler hostapd_private[] = {

+ 59 - 0
core/hdd/src/wlan_hdd_wext.c

@@ -4020,6 +4020,65 @@ int hdd_set_11ax_rate(hdd_adapter_t *adapter, int set_value,
 	return ret;
 }
 
+/**
+ * hdd_get_aid_rc() - Get AID and rate code passed from user
+ * @aid: pointer to AID
+ * @rc: pointer to rate code
+ * @set_value: value passed from user
+ *
+ * If target is 11ax capable, set_value will have AID left shifted 16 bits
+ * and 16 bits for rate code. If the target is not 11ax capable, rate code
+ * will only be 8 bits.
+ *
+ * Return: None
+ */
+static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
+{
+	uint8_t rc_bits;
+
+	if (sme_is_feature_supported_by_fw(DOT11AX))
+		rc_bits = 16;
+	else
+		rc_bits = 8;
+
+	*aid = set_value >> rc_bits;
+	*rc = set_value & ((1 << (rc_bits + 1)) - 1);
+}
+
+int hdd_set_peer_rate(hdd_adapter_t *adapter, int set_value)
+{
+	uint8_t aid, *peer_mac;
+	uint16_t rc;
+	QDF_STATUS status;
+
+	if (adapter->device_mode != QDF_SAP_MODE) {
+		hdd_err("Invalid devicde mode - %d", adapter->device_mode);
+		return -EINVAL;
+	}
+
+	hdd_get_aid_rc(&aid, &rc, set_value);
+
+	if ((adapter->aStaInfo[aid].isUsed) &&
+	    (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
+		peer_mac =
+		    (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
+		hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
+			 aid, MAC_ADDR_ARRAY(peer_mac));
+	} else {
+		hdd_err("No matching peer found for AID: %d", aid);
+		return -EINVAL;
+	}
+
+	status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
+				    rc, adapter->sessionId);
+	if (status != QDF_STATUS_SUCCESS) {
+		hdd_err("Failed to set peer fixed rate - status: %d", status);
+		return -EIO;
+	}
+
+	return 0;
+}
+
 /**
  * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
  * @dev: device upon which the ioctl was received

+ 14 - 0
core/sme/inc/sme_api.h

@@ -1275,6 +1275,20 @@ QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
 					uint8_t session_id, uint8_t *vendor_ie,
 					int access_policy);
 
+/**
+ * sme_set_peer_param() - set peer param
+ * @vdev_id: vdev ID
+ * @peer_addr: peer MAC address
+ * @param_id: param ID to be updated
+ * @param_Value: paraam value
+ *
+ * This SME API is used to send the peer param to WMA to be sent to FW.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
+			      uint32_t param_value, uint32_t vdev_id);
+
 QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal,
 		enum sta_roam_policy_dfs_mode dfs_mode,
 		bool skip_unsafe_channels,

+ 16 - 0
core/sme/src/common/sme_api.c

@@ -16487,3 +16487,19 @@ QDF_STATUS sme_delete_all_tdls_peers(tHalHandle hal, uint8_t session_id)
 
 	return status;
 }
+
+QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
+			      uint32_t param_value, uint32_t vdev_id)
+{
+	void *wma_handle;
+
+	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
+	if (!wma_handle) {
+		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
+				"wma handle is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return wma_set_peer_param(wma_handle, peer_addr, param_id,
+				  param_value, vdev_id);
+}