From patchwork Thu Sep 17 14:32:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 7207991 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C0129F380 for ; Thu, 17 Sep 2015 14:33:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16140205F3 for ; Thu, 17 Sep 2015 14:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDDA5207A4 for ; Thu, 17 Sep 2015 14:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbbIQOdn (ORCPT ); Thu, 17 Sep 2015 10:33:43 -0400 Received: from mga01.intel.com ([192.55.52.88]:6821 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbbIQOdj (ORCPT ); Thu, 17 Sep 2015 10:33:39 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 17 Sep 2015 07:33:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,547,1437462000"; d="scan'208";a="791759268" Received: from aotchere-mobl1.ger.corp.intel.com ([10.12.85.62]) by fmsmga001.fm.intel.com with ESMTP; 17 Sep 2015 07:33:38 -0700 From: andrei.otcheretianski@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, emmanuel.grumbach@intel.com, Andrei Otcheretianski Subject: [RFC 6/7] mac80211: Implement add_nan_func and rm_nan_func Date: Thu, 17 Sep 2015 17:32:30 +0300 Message-Id: <1442500351-8780-7-git-send-email-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.5.2.windows.2 In-Reply-To: <1442500351-8780-1-git-send-email-andrei.otcheretianski@intel.com> References: <1442500351-8780-1-git-send-email-andrei.otcheretianski@intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrei Otcheretianski Add a trivial implementation for add/rm_nan_func functions. Currently mac80211 just passes the configuration to the driver. Signed-off-by: Andrei Otcheretianski --- include/net/mac80211.h | 17 ++++++++++++++- net/mac80211/cfg.c | 30 +++++++++++++++++++++++++++ net/mac80211/driver-ops.h | 31 +++++++++++++++++++++++++++ net/mac80211/trace.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index c4d8f4a..ebe0921 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -3250,7 +3250,12 @@ enum ieee80211_reconfig_type { * * @start_nan: join an existing nan cluster, or create a new one. * @stop_nan: leave the nan cluster. - */ + * @add_nan_func: Add a nan function. Returns a stricly positive instance id + * upon success. The data in cfg80211_nan_func must not be referenced + * outside the scope of this call. + * @rm_nan_func: Remove a nan function. + * @nan_change_conf: changes NAN configuration. + */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, @@ -3495,6 +3500,16 @@ struct ieee80211_ops { struct cfg80211_nan_conf *conf); int (*stop_nan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); + int (*add_nan_func)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + const struct cfg80211_nan_func *nan_func); + void (*rm_nan_func)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + u8 instance_id); + int (*nan_change_conf)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_nan_conf *conf, + u32 changes); }; /** diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index e36d542..8a504ae 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -163,6 +163,34 @@ static void ieee80211_stop_nan(struct wiphy *wiphy, ieee80211_sdata_stop(sdata); } +static int ieee80211_add_nan_func(struct wiphy *wiphy, + struct wireless_dev *wdev, + const struct cfg80211_nan_func *nan_func) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + + if (sdata->vif.type != NL80211_IFTYPE_NAN) + return -EOPNOTSUPP; + + if (!ieee80211_sdata_running(sdata)) + return -ENETDOWN; + + return drv_add_nan_func(sdata->local, sdata, nan_func); +} + +static void ieee80211_rm_nan_func(struct wiphy *wiphy, + struct wireless_dev *wdev, + u8 instance_id) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + + if (sdata->vif.type != NL80211_IFTYPE_NAN || + !ieee80211_sdata_running(sdata)) + return; + + drv_rm_nan_func(sdata->local, sdata, instance_id); +} + static int ieee80211_set_noack_map(struct wiphy *wiphy, struct net_device *dev, u16 noack_map) @@ -3942,4 +3970,6 @@ const struct cfg80211_ops mac80211_config_ops = { .del_tx_ts = ieee80211_del_tx_ts, .start_nan = ieee80211_start_nan, .stop_nan = ieee80211_stop_nan, + .add_nan_func = ieee80211_add_nan_func, + .rm_nan_func = ieee80211_rm_nan_func, }; diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 2ef2997..0d6c622 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -1399,4 +1399,35 @@ static inline void drv_stop_nan(struct ieee80211_local *local, trace_drv_return_void(local); } +static inline int drv_add_nan_func(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + const struct cfg80211_nan_func *nan_func) +{ + int ret; + + might_sleep(); + check_sdata_in_driver(sdata); + + if (!local->ops->add_nan_func) + return -EOPNOTSUPP; + + trace_drv_add_nan_func(local, sdata, nan_func); + ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func); + trace_drv_return_int(local, ret); + + return ret; +} + +static inline void drv_rm_nan_func(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + u8 instance_id) +{ + might_sleep(); + check_sdata_in_driver(sdata); + + trace_drv_rm_nan_func(local, sdata, instance_id); + if (local->ops->rm_nan_func) + local->ops->rm_nan_func(&local->hw, &sdata->vif, instance_id); + trace_drv_return_void(local); +} #endif /* __MAC80211_DRIVER_OPS */ diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index a98c864..ca79e83 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h @@ -1739,6 +1739,59 @@ TRACE_EVENT(drv_stop_nan, ) ); +/* TODO: record more fields */ +TRACE_EVENT(drv_add_nan_func, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + const struct cfg80211_nan_func *func), + + TP_ARGS(local, sdata, func), + TP_STRUCT__entry( + LOCAL_ENTRY + VIF_ENTRY + __field(u8, type) + ), + + TP_fast_assign( + LOCAL_ASSIGN; + VIF_ASSIGN; + __entry->type = func->type; + ), + + TP_printk( + LOCAL_PR_FMT VIF_PR_FMT + ", type: %u", + LOCAL_PR_ARG, VIF_PR_ARG, __entry->type + ) +); + + +TRACE_EVENT(drv_rm_nan_func, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + u8 instance_id), + + TP_ARGS(local, sdata, instance_id), + TP_STRUCT__entry( + LOCAL_ENTRY + VIF_ENTRY + __field(u8, instance_id) + ), + + TP_fast_assign( + LOCAL_ASSIGN; + VIF_ASSIGN; + __entry->instance_id = instance_id; + ), + + TP_printk( + LOCAL_PR_FMT VIF_PR_FMT + ", instance_id: %u", + LOCAL_PR_ARG, VIF_PR_ARG, __entry->instance_id + ) +); + + /* * Tracing for API calls that drivers call. */