]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: Add support to indicate that a new interface is to be added
authorIlan Peer <ilan.peer@intel.com>
Mon, 7 Oct 2024 12:00:45 +0000 (15:00 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 23 Oct 2024 14:42:56 +0000 (16:42 +0200)
Add support to indicate to the driver that an interface is about to be
added so that the driver could prepare its resources early if it needs
so.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241007144851.e0e8563e1c30.Ifccc96a46a347eb15752caefc9f4eff31f75ed47@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/cfg.c
net/mac80211/driver-ops.h
net/mac80211/trace.h

index 333e0fae6796c8497ef481f573f5f3ed11f3cf43..0b8df8ec5a3b0ca1864d85f5a8d09eba679de709 100644 (file)
@@ -4444,6 +4444,12 @@ struct ieee80211_prep_tx_info {
  *     if the requested TID-To-Link mapping can be accepted or not.
  *     If it's not accepted the driver may suggest a preferred mapping and
  *     modify @ttlm parameter with the suggested TID-to-Link mapping.
+ * @prep_add_interface: prepare for interface addition. This can be used by
+ *      drivers to prepare for the addition of a new interface, e.g., allocate
+ *      the needed resources etc. This callback doesn't guarantee that an
+ *      interface with the specified type would be added, and thus drivers that
+ *      implement this callback need to handle such cases. The type is the full
+ *      &enum nl80211_iftype.
  */
 struct ieee80211_ops {
        void (*tx)(struct ieee80211_hw *hw,
@@ -4828,6 +4834,8 @@ struct ieee80211_ops {
        enum ieee80211_neg_ttlm_res
        (*can_neg_ttlm)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                        struct ieee80211_neg_ttlm *ttlm);
+       void (*prep_add_interface)(struct ieee80211_hw *hw,
+                                  enum nl80211_iftype type);
 };
 
 /**
index 847304a3a29a9631174cb63823f119f844f57759..ce9558cd1576cb5c1812da26b1e5050199778671 100644 (file)
@@ -194,6 +194,24 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
                }
        }
 
+       /* Let the driver know that an interface is going to be added.
+        * Indicate so only for interface types that will be added to the
+        * driver.
+        */
+       switch (type) {
+       case NL80211_IFTYPE_AP_VLAN:
+               break;
+       case NL80211_IFTYPE_MONITOR:
+               if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) ||
+                   !(params->flags & MONITOR_FLAG_ACTIVE))
+                       break;
+               fallthrough;
+       default:
+               drv_prep_add_interface(local,
+                                      ieee80211_vif_type_p2p(&sdata->vif));
+               break;
+       }
+
        return wdev;
 }
 
index d382d9729e853f8578fd21105714bbc93f60c40a..48bc2da728c086c02b62f8d0c6daebd6af2084a6 100644 (file)
@@ -1728,4 +1728,16 @@ drv_can_neg_ttlm(struct ieee80211_local *local,
 
        return res;
 }
+
+static inline void
+drv_prep_add_interface(struct ieee80211_local *local,
+                      enum nl80211_iftype type)
+{
+       trace_drv_prep_add_interface(local, type);
+       if (local->ops->prep_add_interface)
+               local->ops->prep_add_interface(&local->hw, type);
+
+       trace_drv_return_void(local);
+}
+
 #endif /* __MAC80211_DRIVER_OPS */
index dc498cd8cd91916932f0719da9f302c6b6942dde..e6f0ce8e5d435144e1802379064a5606c05cb80d 100644 (file)
@@ -3154,6 +3154,25 @@ TRACE_EVENT(drv_neg_ttlm_res,
                  LOCAL_PR_ARG, VIF_PR_ARG, __entry->res
        )
 );
+
+TRACE_EVENT(drv_prep_add_interface,
+           TP_PROTO(struct ieee80211_local *local,
+                    enum nl80211_iftype type),
+
+       TP_ARGS(local, type),
+       TP_STRUCT__entry(LOCAL_ENTRY
+                        __field(u32, type)
+       ),
+
+       TP_fast_assign(LOCAL_ASSIGN;
+                      __entry->type = type;
+       ),
+
+       TP_printk(LOCAL_PR_FMT  " type: %u\n ",
+                 LOCAL_PR_ARG, __entry->type
+       )
+);
+
 #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH