From patchwork Mon Oct 15 14:49:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1594281 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6686CDFB34 for ; Mon, 15 Oct 2012 14:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751261Ab2JOOti (ORCPT ); Mon, 15 Oct 2012 10:49:38 -0400 Received: from latitanza.investici.org ([82.94.249.234]:34835 "EHLO latitanza.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750781Ab2JOOth (ORCPT ); Mon, 15 Oct 2012 10:49:37 -0400 Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 94DB99812E; Mon, 15 Oct 2012 14:49:35 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org 94DB99812E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1350312576; bh=EgqUTPMnzEyTParG453R/qCzXCiuJy81s3b7Edd2QLU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=BtvZlVDgddrflNvsu0cxbl9xR+As2LrHLlREHMnU7Y6X1U/4jDa0vefQSvzkoTEWP Ll2Wi4waEYTKNfv/r1gQxVjv/L14q/i2tc04HAeFCxFz1oRXkIK3FruK088wHFtq8L p1KXKObEs49W0qdlWSA+oQLbB0IPAvLI9mgYldTE= From: Antonio Quartulli To: Johannes Berg Cc: "John W. Linville" , linux-wireless@vger.kernel.org, Antonio Quartulli Subject: [PATCH 2/2] cfg80211: add the NL80211_CMD_SET_MCAST_RATE command Date: Mon, 15 Oct 2012 16:49:01 +0200 Message-Id: <1350312541-17657-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.12.3 In-Reply-To: <1350312541-17657-1-git-send-email-ordex@autistici.org> References: <1350312541-17657-1-git-send-email-ordex@autistici.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org this command triggers the set_mcast_rate() callback, so enabling the user to change the rate used to send multicast frames for vif configured as IBSS or MESH_POINT Signed-off-by: Antonio Quartulli --- include/linux/nl80211.h | 5 +++++ net/wireless/nl80211.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 0e6277a..9440a2d 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -578,6 +578,9 @@ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON * is used for this. * + * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames + * for IBSS or MESH vif. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -726,6 +729,8 @@ enum nl80211_commands { NL80211_CMD_CONN_FAILED, + NL80211_CMD_SET_MCAST_RATE, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 38a1a57..f537393 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5435,6 +5435,35 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info) return cfg80211_leave_ibss(rdev, dev, false); } +static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + int mcast_rate[IEEE80211_NUM_BANDS]; + u32 nla_rate; + int err; + + memset(mcast_rate, 0, sizeof(mcast_rate)); + + if (!info->attrs[NL80211_ATTR_MCAST_RATE]) + return -EINVAL; + + nla_rate = nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); + if (!nl80211_parse_mcast_rate(rdev, mcast_rate, nla_rate)) + return -EINVAL; + + mutex_lock(&rdev->devlist_mtx); + wdev_lock(dev->ieee80211_ptr); + + err = rdev->ops->set_mcast_rate(&rdev->wiphy, dev, mcast_rate); + + wdev_unlock(dev->ieee80211_ptr); + mutex_unlock(&rdev->devlist_mtx); + + return err; +} + + #ifdef CONFIG_NL80211_TESTMODE static struct genl_multicast_group nl80211_testmode_mcgrp = { .name = "testmode", @@ -7620,6 +7649,14 @@ static struct genl_ops nl80211_ops[] = { .internal_flags = NL80211_FLAG_NEED_WDEV_UP | NL80211_FLAG_NEED_RTNL, }, + { + .cmd = NL80211_CMD_SET_MCAST_RATE, + .doit = nl80211_set_mcast_rate, + .policy = nl80211_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_NETDEV | + NL80211_FLAG_NEED_RTNL, + }, }; static struct genl_multicast_group nl80211_mlme_mcgrp = {