[PATCH v3 16/46] PR: Add nl80211 driver support for PD interface

Kavita Kavita kavita.kavita at oss.qualcomm.com
Wed May 13 02:59:40 PDT 2026


From: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>

Proximity Detection (PD) ranging requires a dedicated virtual
interface with its own MAC address, separate from the station
interface.

Add WPA_IF_PD to the driver interface type enum and wire it
through the nl80211 driver. A dedicated netlink socket (nl_pr)
is created when the PD interface is brought up, mirroring the
existing nl_nan socket used for NAN. The new nl80211_set_pr_dev()
function sends NL80211_CMD_START_PD and NL80211_CMD_STOP_PD to
the kernel. Interface creation routes the PD type through
the nl_pr socket and registers it for eloop event reception.

Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
---
 src/drivers/driver.h         |  5 +++++
 src/drivers/driver_nl80211.c | 35 ++++++++++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 18c51b75c..ba53dc60d 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2169,6 +2169,11 @@ enum wpa_driver_if_type {
 	 */
 	WPA_IF_NAN_DATA,
 
+	/*
+	 * WPA_IF_PD - PD Device
+	 */
+	WPA_IF_PD,
+
 	/* keep last */
 	WPA_IF_MAX
 };
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 3b50ffca3..a5b44d9d6 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -248,7 +248,8 @@ static int is_p2p_net_interface(enum nl80211_iftype nlmode)
 
 static bool nl80211_is_netdev_iftype(enum nl80211_iftype t)
 {
-	return t != NL80211_IFTYPE_P2P_DEVICE && t != NL80211_IFTYPE_NAN;
+	return t != NL80211_IFTYPE_P2P_DEVICE && t != NL80211_IFTYPE_NAN &&
+		t != NL80211_IFTYPE_PD;
 }
 
 
@@ -3239,6 +3240,22 @@ static int nl80211_set_p2pdev(struct i802_bss *bss, int start)
 	return ret;
 }
 
+static int nl80211_set_pr_dev(struct i802_bss *bss, int start)
+{
+	struct nl_msg *msg;
+	int ret;
+
+	msg = nl80211_cmd_msg(bss, 0, start ? NL80211_CMD_START_PD :
+			      NL80211_CMD_STOP_PD);
+	ret = send_and_recv_cmd(bss->drv, msg);
+
+	wpa_printf(MSG_DEBUG, "nl80211: %s PD Device %s (0x%llx): %s",
+		   start ? "Start" : "Stop",
+		   bss->ifname, (unsigned long long)bss->wdev_id,
+		   strerror(-ret));
+	return ret;
+}
+
 
 #ifdef CONFIG_NAN
 static void nl80211_nan_stop(struct i802_bss *bss)
@@ -3297,6 +3314,11 @@ static int i802_set_iface_flags(struct i802_bss *bss, int up)
 	if (nlmode == NL80211_IFTYPE_NAN)
 		return nl80211_set_nandev(bss, up);
 
+	if (nlmode == NL80211_IFTYPE_PD) {
+		/* PR Device has start/stop which is equivalent */
+		return nl80211_set_pr_dev(bss, up);
+	}
+
 	return linux_set_iface_flags(bss->drv->global->ioctl_sock,
 				     bss->ifname, up);
 }
@@ -3492,7 +3514,8 @@ wpa_driver_nl80211_finish_drv_init(struct i802_bss *bss, const u8 *set_addr,
 			nl80211_disable_11b_rates(bss->drv,
 						  bss->drv->ifindex, 1);
 
-		if (nlmode == NL80211_IFTYPE_P2P_DEVICE)
+		if (nlmode == NL80211_IFTYPE_P2P_DEVICE ||
+		    nlmode == NL80211_IFTYPE_PD)
 			return ret;
 	} else {
 		wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
@@ -4856,7 +4879,8 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data,
 	}
 
 	if ((is_sta_interface(drv->nlmode) ||
-	     drv->nlmode == NL80211_IFTYPE_P2P_DEVICE) &&
+	     drv->nlmode == NL80211_IFTYPE_P2P_DEVICE ||
+	     drv->nlmode == NL80211_IFTYPE_PD) &&
 	    WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
 	    WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) {
 		if (freq == 0 &&
@@ -6662,6 +6686,8 @@ const char * nl80211_iftype_str(enum nl80211_iftype mode)
 		return "NAN DEVICE";
 	case NL80211_IFTYPE_NAN_DATA:
 		return "NAN_DATA";
+	case NL80211_IFTYPE_PD:
+		return "PD DEVICE";
 	default:
 		return "unknown";
 	}
@@ -6699,6 +6725,7 @@ static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 		goto fail;
 
 	if ((addr && (iftype == NL80211_IFTYPE_P2P_DEVICE ||
+		      iftype == NL80211_IFTYPE_PD ||
 		      iftype == NL80211_IFTYPE_NAN)) &&
 	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr))
 		goto fail;
@@ -9454,6 +9481,8 @@ static enum nl80211_iftype wpa_driver_nl80211_if_type(
 		return NL80211_IFTYPE_NAN;
 	case WPA_IF_NAN_DATA:
 		return NL80211_IFTYPE_NAN_DATA;
+	case WPA_IF_PD:
+		return NL80211_IFTYPE_PD;
 	default:
 		return -1;
 	}
-- 
2.34.1




More information about the Hostap mailing list