[RFC PATCH 08/23] PR: Add nl80211 driver support for PD interface

Peddolla Harshavardhan Reddy peddolla.reddy at oss.qualcomm.com
Tue Mar 31 22:48:46 PDT 2026


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 06dd21e1b..2fd8e896a 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2159,6 +2159,11 @@ enum wpa_driver_if_type {
 	 */
 	WPA_IF_NAN,
 
+	/*
+	 * 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 297f363f4..2e7e5ee3e 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;
 }
 
 
@@ -3185,6 +3186,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)
@@ -3243,6 +3260,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);
 }
@@ -3438,7 +3460,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 "
@@ -4782,7 +4805,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 &&
@@ -6522,6 +6546,8 @@ const char * nl80211_iftype_str(enum nl80211_iftype mode)
 		return "OCB";
 	case NL80211_IFTYPE_NAN:
 		return "NAN DEVICE";
+	case NL80211_IFTYPE_PD:
+		return "PD DEVICE";
 	default:
 		return "unknown";
 	}
@@ -6559,6 +6585,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;
@@ -9296,6 +9323,8 @@ static enum nl80211_iftype wpa_driver_nl80211_if_type(
 		return NL80211_IFTYPE_MESH_POINT;
 	case WPA_IF_NAN:
 		return NL80211_IFTYPE_NAN;
+	case WPA_IF_PD:
+		return NL80211_IFTYPE_PD;
 	default:
 		return -1;
 	}
-- 
2.34.1




More information about the Hostap mailing list