Netdev List
 help / color / mirror / Atom feed
* (unknown), 
From: Liu Wang @ 2011-07-17 15:39 UTC (permalink / raw)





I am Mr. Liu Wang from Taipei. I need your partnership in re-profiling
funds. In summary the funds are coming via the International bank of
Taipei, Taiwan. You shall be entitle to 30% of the funds. Contact me for
further details.

^ permalink raw reply

* Re: [PATCH 0/2] Bluetooth: Fix regressions for 3.0
From: John W. Linville @ 2011-07-17 16:46 UTC (permalink / raw)
  To: David Miller
  Cc: padovan-Y3ZbgMPKUGA34EUeqzHoZw, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110716.101518.1007939482226184514.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

On Sat, Jul 16, 2011 at 10:15:18AM -0700, David Miller wrote:
> From: "Gustavo F. Padovan" <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>
> Date: Sat, 16 Jul 2011 01:30:19 -0300
> 
> > From: "Gustavo F. Padovan" <padovan-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org>
> > 
> > Gustavo F. Padovan (1):
> >   Bluetooth: Fix regression in L2CAP connection procedure
> > 
> > Ilia Kolomisnky (1):
> >   Bluetooth: Fix crash with incoming L2CAP connections
> > 
> >  net/bluetooth/l2cap_core.c |    9 +++++----
> >  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> John I'm going to apply these directly so I can get them to
> Linus in time for 3.0-final.
> 
> Thanks Gustavo.

Yup, looks great -- thanks!

-- 
John W. Linville		Someday the world will need a hero, and you
linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org			might be all we have.  Be ready.

^ permalink raw reply

* [PATCH][RFC] netfilter: Fix small leak in ipq_build_packet_message()
From: Jesper Juhl @ 2011-07-17 17:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: netdev, coreteam, netfilter, netfilter-devel, Hideaki YOSHIFUJI,
	James Morris, Pekka Savola (ipv6), Alexey Kuznetsov,
	David S. Miller, Patrick McHardy

ipq_build_packet_message() in net/ipv4/netfilter/ip_queue.c and
net/ipv6/netfilter/ip6_queue.c contain a small potential mem leak as
far as I can tell.

We allocate memory for 'skb' with alloc_skb() annd then call
 nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));

NLMSG_PUT is a macro
 NLMSG_PUT(skb, pid, seq, type, len) \
  		NLMSG_NEW(skb, pid, seq, type, len, 0)

that expands to NLMSG_NEW, which is also a macro which expands to:
 NLMSG_NEW(skb, pid, seq, type, len, flags) \
  	({	if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
  			goto nlmsg_failure; \
  		__nlmsg_put(skb, pid, seq, type, len, flags); })

If we take the true branch of the 'if' statement and 'goto
nlmsg_failure', then we'll, at that point, return from
ipq_build_packet_message() without having assigned 'skb' to anything
and we'll leak the memory we allocated for it when it goes out of
scope.

Fix this by placing a 'kfree(skb)' at 'nlmsg_failure'.

I admit that I do not know how likely this to actually happen or even
if there's something that guarantees that it will never happen - I'm
not that familiar with this code, but if that is so, I've not been
able to spot it.

Please review and commit if you believe this is correct. Thanks.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/ipv4/netfilter/ip_queue.c  |    1 +
 net/ipv6/netfilter/ip6_queue.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

  Disclaimer: Patch is compile tested only.

diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 5c9b9d9..48f7d5b 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -218,6 +218,7 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)
 	return skb;
 
 nlmsg_failure:
+	kfree_skb(skb);
 	*errp = -EINVAL;
 	printk(KERN_ERR "ip_queue: error creating packet message\n");
 	return NULL;
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 2493948..87b243a 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -218,6 +218,7 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)
 	return skb;
 
 nlmsg_failure:
+	kfree_skb(skb);
 	*errp = -EINVAL;
 	printk(KERN_ERR "ip6_queue: error creating packet message\n");
 	return NULL;
-- 
1.7.6


PS. Please CC me on replies since I'm not subscribed to all the lists 
copied on this mail.

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply related

* [PATCH][TRIVIAL] net, netfilter: Remove redundant goto in ebt_ulog_packet
From: Jesper Juhl @ 2011-07-17 17:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: netdev, bridge, coreteam, netfilter, netfilter-devel,
	David S. Miller, Stephen Hemminger, Patrick McHardy,
	Bart De Schuymer, trivial

In net/bridge/netfilter/ebt_ulog.c:ebt_ulog_packet() the 'goto unlock'
before the 'alloc_failure' label is completely redundant. This patch
removes it.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/bridge/netfilter/ebt_ulog.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index 26377e9..bf2a333 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -216,7 +216,6 @@ unlock:
 nlmsg_failure:
 	pr_debug("error during NLMSG_PUT. This should "
 		 "not happen, please report to author.\n");
-	goto unlock;
 alloc_failure:
 	goto unlock;
 }
-- 
1.7.6


PS. Please CC me on replies since I'm not subscribed to all the lists 
copied on this mail.

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

^ permalink raw reply related

* [PATCH] net: add 802.1ad / 802.1ah / QinQ ethertypes
From: David Lamparter @ 2011-07-17 18:32 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, David Lamparter

define ETH_P_8021AD to 88a8 (assigned by IEEE) and add ETH_P_QINQ{1,2,3}
for the pre-standard 9{1,2,3}00 types. all of them use 802.1q frame
format, with 1 bit used differently in some cases.

also define ETH_P_8021AH to 88e7 (assigned by IEEE). this is Mac-in-Mac
and uses a different, 16-byte header.

Signed-off-by: David Lamparter <equinox@diac24.net>
---
support for these coming up in a few hours, just polishing...

 include/linux/if_ether.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 0065ffd..a3d99ff 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -78,10 +78,15 @@
 					 */
 #define ETH_P_PAE	0x888E		/* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_AOE	0x88A2		/* ATA over Ethernet		*/
+#define ETH_P_8021AD	0x88A8          /* 802.1ad Service VLAN		*/
 #define ETH_P_TIPC	0x88CA		/* TIPC 			*/
+#define ETH_P_8021AH	0x88E7          /* 802.1ah Backbone Service Tag */
 #define ETH_P_1588	0x88F7		/* IEEE 1588 Timesync */
 #define ETH_P_FCOE	0x8906		/* Fibre Channel over Ethernet  */
 #define ETH_P_FIP	0x8914		/* FCoE Initialization Protocol */
+#define ETH_P_QINQ1	0x9100		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_QINQ2	0x9200		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_QINQ3	0x9300		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_EDSA	0xDADA		/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 
 /*
-- 
1.7.5.3


^ permalink raw reply related

* [PATCH 0/3] ath6kl: neatening
From: Joe Perches @ 2011-07-17 18:43 UTC (permalink / raw)
  To: Kalle Valo
  Cc: devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X, gregkh-l3A5Bk7waGM,
	error27-Re5JQEeQqe8AvxtiuMwx3w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

Joe Perches (3):
  ath6kl: Add missing newlines and coalesce messages
  ath6kl: Remove __func__ uses from ath6kl_err
  ath6kl: cfg80211: Add and use ath6kl_cfg80211_ready helper

 drivers/net/wireless/ath/ath6kl/bmi.c      |    2 +-
 drivers/net/wireless/ath/ath6kl/cfg80211.c |  230 ++++++++-------------------
 drivers/net/wireless/ath/ath6kl/debug.c    |    2 +-
 drivers/net/wireless/ath/ath6kl/htc.c      |   15 +-
 drivers/net/wireless/ath/ath6kl/htc_hif.c  |    3 +-
 drivers/net/wireless/ath/ath6kl/init.c     |   79 ++++------
 drivers/net/wireless/ath/ath6kl/main.c     |   16 +-
 drivers/net/wireless/ath/ath6kl/txrx.c     |   53 +++----
 drivers/net/wireless/ath/ath6kl/wmi.c      |   29 ++--
 9 files changed, 155 insertions(+), 274 deletions(-)

-- 
1.7.6.131.g99019

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 1/3] ath6kl: Add missing newlines and coalesce messages
From: Joe Perches @ 2011-07-17 18:43 UTC (permalink / raw)
  To: Kalle Valo, linux-kernel
  Cc: devel, gregkh, error27, John W. Linville, linux-wireless, netdev
In-Reply-To: <cover.1310927985.git.joe@perches.com>

Logging messages should end in newlines.
Multiple ath6kl_dbg uses should be coalesced where possible.
Convert two otherwise identical format strings to the same case to
save some space.
Use __func__ in a couple of places as appropriate.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c |   13 +++++++------
 drivers/net/wireless/ath/ath6kl/debug.c    |    2 +-
 drivers/net/wireless/ath/ath6kl/htc.c      |   18 ++++++++----------
 drivers/net/wireless/ath/ath6kl/init.c     |    5 ++---
 drivers/net/wireless/ath/ath6kl/txrx.c     |   16 ++++++++++------
 drivers/net/wireless/ath/ath6kl/wmi.c      |   21 +++++++++++----------
 6 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index ab75e0a..f556e23 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -360,8 +360,9 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
 		   "%s: connect called with authmode %d dot11 auth %d"
-		   " PW crypto %d PW crypto Len %d GRP crypto %d"
-		   " GRP crypto Len %d channel hint %u\n", __func__,
+		   " PW crypto %d PW crypto len %d GRP crypto %d"
+		   " GRP crypto len %d channel hint %u\n",
+		   __func__,
 		   ar->auth_mode, ar->dot11_auth_mode, ar->prwise_crypto,
 		   ar->prwise_crypto_len, ar->grp_crypto,
 		   ar->grp_crpto_len, ar->ch_hint);
@@ -929,8 +930,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
 		del_timer(&ar->disconnect_timer);
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
-		   "%s: index %d, key_len %d, key_type 0x%x,"
-		   " key_usage 0x%x, seq_len %d\n",
+		   "%s: index %d, key_len %d, key_type 0x%x, key_usage 0x%x, seq_len %d\n",
 		   __func__, key_index, key->key_len, key_type,
 		   key_usage, key->seq_len);
 
@@ -1348,7 +1348,8 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
 		   "%s: connect called with authmode %d dot11 auth %d"
 		   " PW crypto %d PW crypto len %d GRP crypto %d"
-		   " GRP crypto len %d channel hint %u\n", __func__,
+		   " GRP crypto len %d channel hint %u\n",
+		   __func__,
 		   ar->auth_mode, ar->dot11_auth_mode, ar->prwise_crypto,
 		   ar->prwise_crypto_len, ar->grp_crypto,
 		   ar->grp_crpto_len, ar->ch_hint);
@@ -1534,7 +1535,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev,
 		sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
 		sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
 	} else {
-		ath6kl_warn("%s: invalid rate: %d", __func__, rate);
+		ath6kl_warn("%s: invalid rate: %d\n", __func__, rate);
 		return 0;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index ea11e7b..316136c 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -97,7 +97,7 @@ void ath6kl_dump_registers(struct ath6kl_device *dev,
 		ath6kl_dbg(ATH6KL_DBG_ANY, "Counter Int status Enable: 0x%x\n",
 			irq_enable_reg->cntr_int_status_en);
 	}
-	ath6kl_dbg(ATH6KL_DBG_ANY, "<------------------------------->");
+	ath6kl_dbg(ATH6KL_DBG_ANY, "<------------------------------->\n");
 }
 
 static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist)
diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c
index f4fa8d2..f9b2294 100644
--- a/drivers/net/wireless/ath/ath6kl/htc.c
+++ b/drivers/net/wireless/ath/ath6kl/htc.c
@@ -81,8 +81,8 @@ static void htc_tx_comp_update(struct htc_target *target,
 	if (!packet->status)
 		return;
 
-	ath6kl_err("htc_tx_comp_update: req failed "
-		   "(status:%d, ep:%d, len:%d creds:%d)\n",
+	ath6kl_err("%s: req failed (status:%d, ep:%d, len:%d creds:%d)\n",
+		   __func__,
 		   packet->status, packet->endpoint, packet->act_len,
 		   packet->info.tx.cred_used);
 
@@ -176,9 +176,8 @@ static int htc_issue_send(struct htc_target *target, struct htc_packet *packet)
 
 	send_len = packet->act_len + HTC_HDR_LENGTH;
 
-	ath6kl_dbg(ATH6KL_DBG_HTC_SEND,
-		"htc_issue_send: transmit len : %d (%s)\n",
-		send_len, sync ? "sync" : "async");
+	ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "%s: transmit len : %d (%s)\n",
+		   __func__, send_len, sync ? "sync" : "async");
 
 	padded_len = CALC_TXRX_PADDED_LEN(target->dev, send_len);
 
@@ -233,8 +232,8 @@ static int htc_check_credits(struct htc_target *target,
 
 		if (ep->cred_dist.credits < *req_cred) {
 			ath6kl_dbg(ATH6KL_DBG_HTC_SEND,
-				   "not enough credits for ep %d leaving "
-				   "packet in queue\n", eid);
+				   "not enough credits for ep %d - leaving packet in queue\n",
+				   eid);
 			return -EINVAL;
 		}
 	}
@@ -907,9 +906,8 @@ static int dev_rx_pkt(struct htc_target *target, struct htc_packet *packet,
 	padded_len = CALC_TXRX_PADDED_LEN(dev, rx_len);
 
 	if (padded_len > packet->buf_len) {
-		ath6kl_err("dev_rx_pkt, not enough space for padlen:%d "
-			   "recvlen:%d bufferlen:%d\n",
-			   padded_len, rx_len, packet->buf_len);
+		ath6kl_err("%s: not enough space for padlen:%d recvlen:%d bufferlen:%d\n",
+			   __func__, padded_len, rx_len, packet->buf_len);
 		return -ENOMEM;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6094e43..dae5442 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -347,9 +347,8 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
 				(u8 *)&mbox_isr_yield_val,
 				4);
 		if (status) {
-			ath6kl_err("%s: bmi_write_memory for yield "
-				   "limit failed\n",
-				__func__);
+			ath6kl_err("%s: bmi_write_memory for yield limit failed\n",
+				   __func__);
 			goto out;
 		}
 	}
diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c
index c9df26a..1125b37 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -541,10 +541,6 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue)
 		if (!status && (packet->act_len != skb->len))
 			goto fatal;
 
-		ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
-			   "%s: skb=0x%p data=0x%p len=0x%x eid=%d ",
-			   __func__, skb, packet->buf, packet->act_len, eid);
-
 		ar->tx_pending[eid]--;
 
 		if (eid != ar->ctrl_ep)
@@ -568,8 +564,16 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue)
 			if (status != -ENOSPC)
 				ath6kl_err("%s: tx error, status: 0x%x\n",
 					   __func__, status);
+			ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
+				   "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n",
+				   __func__, skb, packet->buf, packet->act_len,
+				   eid, "error!");
 		} else {
-			ath6kl_dbg(ATH6KL_DBG_WLAN_TX, "OK\n");
+			ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
+				   "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n",
+				   __func__, skb, packet->buf, packet->act_len,
+				   eid, "OK");
+
 			flushing = false;
 			ar->net_stats.tx_packets++;
 			ar->net_stats.tx_bytes += skb->len;
@@ -640,7 +644,7 @@ static void ath6kl_alloc_netbufs(struct sk_buff_head *q, u16 num)
 	while (num) {
 		skb = ath6kl_buf_alloc(ATH6KL_BUFFER_SIZE);
 		if (!skb) {
-			ath6kl_err("%s: netbuf allocation failed", __func__);
+			ath6kl_err("%s: netbuf allocation failed\n", __func__);
 			return;
 		}
 		skb_queue_tail(q, skb);
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index 38270bb..5d95b56 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -570,11 +570,11 @@ static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
 	ev = (struct wmi_peer_node_event *) datap;
 
 	if (ev->event_code == PEER_NODE_JOIN_EVENT)
-		ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM",
-			ev->peer_mac_addr);
+		ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
+			   ev->peer_mac_addr);
 	else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
-		ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM",
-			ev->peer_mac_addr);
+		ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
+			   ev->peer_mac_addr);
 
 	return 0;
 }
@@ -1027,24 +1027,25 @@ static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len)
  */
 static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
 {
+	const char *type = "unknown error";
 	struct wmi_cmd_error_event *ev;
-
 	ev = (struct wmi_cmd_error_event *) datap;
 
-	ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d ", ev->cmd_id);
-
 	switch (ev->err_code) {
 	case INVALID_PARAM:
-		ath6kl_dbg(ATH6KL_DBG_WMI, "illegal parameter\n");
+		type = "invalid parameter";
 		break;
 	case ILLEGAL_STATE:
-		ath6kl_dbg(ATH6KL_DBG_WMI, "illegal state\n");
+		type = "invalid state";
 		break;
 	case INTERNAL_ERROR:
-		ath6kl_dbg(ATH6KL_DBG_WMI, "internal error\n");
+		type = "internal error";
 		break;
 	}
 
+	ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
+		   ev->cmd_id, type);
+
 	return 0;
 }
 
-- 
1.7.6.131.g99019

^ permalink raw reply related

* [PATCH 2/3] ath6kl: Remove __func__ uses from ath6kl_err
From: Joe Perches @ 2011-07-17 18:43 UTC (permalink / raw)
  To: Kalle Valo, linux-kernel
  Cc: devel, gregkh, error27, John W. Linville, linux-wireless, netdev
In-Reply-To: <cover.1310927985.git.joe@perches.com>

Remove unnecessary clutter from ath6kl_err messages.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/ath/ath6kl/bmi.c      |    2 +-
 drivers/net/wireless/ath/ath6kl/cfg80211.c |  129 +++++++++++++--------------
 drivers/net/wireless/ath/ath6kl/htc.c      |    7 +-
 drivers/net/wireless/ath/ath6kl/htc_hif.c  |    3 +-
 drivers/net/wireless/ath/ath6kl/init.c     |   78 +++++++----------
 drivers/net/wireless/ath/ath6kl/main.c     |   16 ++--
 drivers/net/wireless/ath/ath6kl/txrx.c     |   39 ++++-----
 drivers/net/wireless/ath/ath6kl/wmi.c      |    8 +-
 8 files changed, 125 insertions(+), 157 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c
index 1aed4f1..8467669 100644
--- a/drivers/net/wireless/ath/ath6kl/bmi.c
+++ b/drivers/net/wireless/ath/ath6kl/bmi.c
@@ -55,7 +55,7 @@ static int ath6kl_get_bmi_cmd_credits(struct ath6kl *ar)
 	}
 
 	if (!ar->bmi.cmd_credits) {
-		ath6kl_err("%s bmi communication timeout\n", __func__);
+		ath6kl_err("bmi communication timeout\n");
 		return -ETIMEDOUT;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index f556e23..34df184 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -196,7 +196,7 @@ static int ath6kl_set_cipher(struct ath6kl *ar, u32 cipher, bool ucast)
 		*ar_cipher_len = 0;
 		break;
 	default:
-		ath6kl_err("%s: cipher 0x%x not supported\n", __func__, cipher);
+		ath6kl_err("cipher 0x%x not supported\n", cipher);
 		return -ENOTSUPP;
 	}
 
@@ -226,40 +226,39 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 	ar->sme_state = SME_CONNECTING;
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready yet\n", __func__);
+		ath6kl_err("wmi is not ready yet\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
 	if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) {
-		ath6kl_err("%s: destroy in progress\n", __func__);
+		ath6kl_err("destroy in progress\n");
 		return -EBUSY;
 	}
 
 	if (!sme->ssid_len || sme->ssid_len > IEEE80211_MAX_SSID_LEN) {
-		ath6kl_err("%s: ssid invalid\n", __func__);
+		ath6kl_err("ssid invalid\n");
 		return -EINVAL;
 	}
 
 	if (test_bit(SKIP_SCAN, &ar->flag) &&
 	    ((sme->channel && sme->channel->center_freq == 0) ||
 	     (sme->bssid && is_zero_ether_addr(sme->bssid)))) {
-		ath6kl_err("%s: SkipScan: channel or bssid invalid\n",
-			   __func__);
+		ath6kl_err("SkipScan: channel or bssid invalid\n");
 		return -EINVAL;
 	}
 
 	if (down_interruptible(&ar->sem)) {
-		ath6kl_err("%s: busy, couldn't get access\n", __func__);
+		ath6kl_err("busy, couldn't get access\n");
 		return -ERESTARTSYS;
 	}
 
 	if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) {
-		ath6kl_err("%s: busy, destroy in progress\n", __func__);
+		ath6kl_err("busy, destroy in progress\n");
 		up(&ar->sem);
 		return -EBUSY;
 	}
@@ -272,7 +271,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 			ar->tx_pending[ath6kl_wmi_get_control_ep(ar->wmi)] == 0,
 			WMI_TIMEOUT);
 		if (signal_pending(current)) {
-			ath6kl_err("%s: cmd queue drain timeout\n", __func__);
+			ath6kl_err("cmd queue drain timeout\n");
 			up(&ar->sem);
 			return -EINTR;
 		}
@@ -287,7 +286,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
 		up(&ar->sem);
 		if (status) {
-			ath6kl_err("%s: wmi_reconnect_cmd failed\n", __func__);
+			ath6kl_err("wmi_reconnect_cmd failed\n");
 			return -EIO;
 		}
 		return 0;
@@ -326,8 +325,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
 		if (sme->key_idx < WMI_MIN_KEY_INDEX ||
 		    sme->key_idx > WMI_MAX_KEY_INDEX) {
-			ath6kl_err("%s: key index %d out of bounds\n",
-				   __func__, sme->key_idx);
+			ath6kl_err("key index %d out of bounds\n",
+				   sme->key_idx);
 			up(&ar->sem);
 			return -ENOENT;
 		}
@@ -349,8 +348,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
 	if (!ar->usr_bss_filter) {
 		if (ath6kl_wmi_bssfilter_cmd(ar->wmi, ALL_BSS_FILTER, 0) != 0) {
-			ath6kl_err("%s: couldn't set bss filtering\n",
-				   __func__);
+			ath6kl_err("couldn't set bss filtering\n");
 			up(&ar->sem);
 			return -EIO;
 		}
@@ -382,10 +380,10 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 	if (status == -EINVAL) {
 		memset(ar->ssid, 0, sizeof(ar->ssid));
 		ar->ssid_len = 0;
-		ath6kl_err("%s: invalid request\n", __func__);
+		ath6kl_err("invalid request\n");
 		return -ENOENT;
 	} else if (status) {
-		ath6kl_err("%s: ath6kl_wmi_connect_cmd failed\n", __func__);
+		ath6kl_err("ath6kl_wmi_connect_cmd failed\n");
 		return -EIO;
 	}
 
@@ -521,7 +519,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel,
 
 	ieeemgmtbuf = kzalloc(size, GFP_ATOMIC);
 	if (!ieeemgmtbuf) {
-		ath6kl_err("%s: ieee mgmt buf alloc error\n", __func__);
+		ath6kl_err("ieee mgmt buf alloc error\n");
 		cfg80211_put_bss(bss);
 		return;
 	}
@@ -578,22 +576,22 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy,
 		   reason_code);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
 	if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) {
-		ath6kl_err("%s: busy, destroy in progress\n", __func__);
+		ath6kl_err("busy, destroy in progress\n");
 		return -EBUSY;
 	}
 
 	if (down_interruptible(&ar->sem)) {
-		ath6kl_err("%s: busy, couldn't get access\n", __func__);
+		ath6kl_err("busy, couldn't get access\n");
 		return -ERESTARTSYS;
 	}
 
@@ -685,7 +683,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason,
 	 */
 	key = &ar->keys[ar->def_txkey_index];
 	if (down_interruptible(&ar->sem)) {
-		ath6kl_err("%s: busy, couldn't get access\n", __func__);
+		ath6kl_err("busy, couldn't get access\n");
 		return;
 	}
 
@@ -746,7 +744,7 @@ static void ath6kl_cfg80211_scan_node(void *arg, struct bss *ni)
 	size = ni->ni_framelen + offsetof(struct ieee80211_mgmt, u);
 	ieeemgmtbuf = kmalloc(size, GFP_ATOMIC);
 	if (!ieeemgmtbuf) {
-		ath6kl_err("%s: ieee mgmt buf alloc error\n", __func__);
+		ath6kl_err("ieee mgmt buf alloc error\n");
 		return;
 	}
 
@@ -784,12 +782,12 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
 	u32 force_fg_scan = 0;
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -798,8 +796,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
 					     (test_bit(CONNECTED, &ar->flag) ?
 					     ALL_BUT_BSS_FILTER :
 					     ALL_BSS_FILTER), 0) != 0) {
-			ath6kl_err("%s: couldn't set bss filtering\n",
-				   __func__);
+			ath6kl_err("couldn't set bss filtering\n");
 			return -EIO;
 		}
 	}
@@ -822,7 +819,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
 
 	if (ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, force_fg_scan,
 				     false, 0, 0, 0, NULL) != 0) {
-		ath6kl_err("%s: wmi_startscan_cmd failed\n", __func__);
+		ath6kl_err("wmi_startscan_cmd failed\n");
 		ret = -EIO;
 	}
 
@@ -870,12 +867,12 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
 	int status = 0;
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -955,12 +952,12 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -995,12 +992,12 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1037,12 +1034,12 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1085,12 +1082,12 @@ static int ath6kl_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1119,20 +1116,19 @@ static int ath6kl_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
 		   changed);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
 	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
 		ret = ath6kl_wmi_set_rts_cmd(ar->wmi, wiphy->rts_threshold);
 		if (ret != 0) {
-			ath6kl_err("%s: ath6kl_wmi_set_rts_cmd failed\n",
-				   __func__);
+			ath6kl_err("ath6kl_wmi_set_rts_cmd failed\n");
 			return -EIO;
 		}
 	}
@@ -1155,12 +1151,12 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy,
 		   type, dbm);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1186,12 +1182,12 @@ static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
 	struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1199,8 +1195,7 @@ static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
 		ar->tx_pwr = 0;
 
 		if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi) != 0) {
-			ath6kl_err("%s: ath6kl_wmi_get_tx_pwr_cmd failed\n",
-				    __func__);
+			ath6kl_err("ath6kl_wmi_get_tx_pwr_cmd failed\n");
 			return -EIO;
 		}
 
@@ -1208,7 +1203,7 @@ static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
 						 5 * HZ);
 
 		if (signal_pending(current)) {
-			ath6kl_err("%s: target did not respond\n", __func__);
+			ath6kl_err("target did not respond\n");
 			return -EINTR;
 		}
 	}
@@ -1228,12 +1223,12 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 		   __func__, pmgmt, timeout);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1246,7 +1241,7 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 	}
 
 	if (ath6kl_wmi_powermode_cmd(ar->wmi, mode.pwr_mode) != 0) {
-		ath6kl_err("%s: wmi_powermode_cmd failed\n", __func__);
+		ath6kl_err("wmi_powermode_cmd failed\n");
 		return -EIO;
 	}
 
@@ -1264,12 +1259,12 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type %u\n", __func__, type);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1281,7 +1276,7 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy,
 		ar->next_mode = ADHOC_NETWORK;
 		break;
 	default:
-		ath6kl_err("%s: invalid type %u\n", __func__, type);
+		ath6kl_err("invalid interface type %u\n", type);
 		return -EOPNOTSUPP;
 	}
 
@@ -1298,18 +1293,18 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy,
 	int status;
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
-	if (!ibss_param->ssid_len
-	    || IEEE80211_MAX_SSID_LEN < ibss_param->ssid_len) {
-		ath6kl_err("%s: ssid invalid\n", __func__);
+	if (!ibss_param->ssid_len ||
+	    IEEE80211_MAX_SSID_LEN < ibss_param->ssid_len) {
+		ath6kl_err("ssid invalid\n");
 		return -EINVAL;
 	}
 
@@ -1373,12 +1368,12 @@ static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy,
 	struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(dev);
 
 	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("%s: wmi is not ready\n", __func__);
+		ath6kl_err("wmi is not ready\n");
 		return -EIO;
 	}
 
 	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("%s: wlan disabled\n", __func__);
+		ath6kl_err("wlan disabled\n");
 		return -EIO;
 	}
 
@@ -1535,7 +1530,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev,
 		sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
 		sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
 	} else {
-		ath6kl_warn("%s: invalid rate: %d\n", __func__, rate);
+		ath6kl_warn("invalid rate: %d\n", rate);
 		return 0;
 	}
 
@@ -1597,14 +1592,14 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev)
 
 	wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
 	if (!wdev) {
-		ath6kl_err("%s: couldn't allocate wireless device\n", __func__);
+		ath6kl_err("couldn't allocate wireless device\n");
 		return NULL;
 	}
 
 	/* create a new wiphy for use with cfg80211 */
 	wdev->wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl));
 	if (!wdev->wiphy) {
-		ath6kl_err("%s: couldn't allocate wiphy device\n", __func__);
+		ath6kl_err("couldn't allocate wiphy device\n");
 		kfree(wdev);
 		return NULL;
 	}
@@ -1625,7 +1620,7 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev)
 
 	ret = wiphy_register(wdev->wiphy);
 	if (ret < 0) {
-		ath6kl_err("%s: couldn't register wiphy device\n", __func__);
+		ath6kl_err("couldn't register wiphy device\n");
 		wiphy_free(wdev->wiphy);
 		kfree(wdev);
 		return NULL;
diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c
index f9b2294..95c47bb 100644
--- a/drivers/net/wireless/ath/ath6kl/htc.c
+++ b/drivers/net/wireless/ath/ath6kl/htc.c
@@ -81,8 +81,7 @@ static void htc_tx_comp_update(struct htc_target *target,
 	if (!packet->status)
 		return;
 
-	ath6kl_err("%s: req failed (status:%d, ep:%d, len:%d creds:%d)\n",
-		   __func__,
+	ath6kl_err("req failed (status:%d, ep:%d, len:%d creds:%d)\n",
 		   packet->status, packet->endpoint, packet->act_len,
 		   packet->info.tx.cred_used);
 
@@ -906,8 +905,8 @@ static int dev_rx_pkt(struct htc_target *target, struct htc_packet *packet,
 	padded_len = CALC_TXRX_PADDED_LEN(dev, rx_len);
 
 	if (padded_len > packet->buf_len) {
-		ath6kl_err("%s: not enough space for padlen:%d recvlen:%d bufferlen:%d\n",
-			   __func__, padded_len, rx_len, packet->buf_len);
+		ath6kl_err("not enough receive space for packet - padlen:%d recvlen:%d bufferlen:%d\n",
+			   padded_len, rx_len, packet->buf_len);
 		return -ENOMEM;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.c b/drivers/net/wireless/ath/ath6kl/htc_hif.c
index bc06b3d..1bcaaec 100644
--- a/drivers/net/wireless/ath/ath6kl/htc_hif.c
+++ b/drivers/net/wireless/ath/ath6kl/htc_hif.c
@@ -553,8 +553,7 @@ static int proc_pending_irqs(struct ath6kl_device *dev, bool *done)
 				rg = &dev->irq_proc_reg;
 				lk_ahd = le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]);
 				if (!lk_ahd)
-					ath6kl_err("%s():lookAhead is zero!\n",
-						   __func__);
+					ath6kl_err("lookAhead is zero!\n");
 			}
 		}
 	}
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index dae5442..fe61871 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -162,8 +162,8 @@ static int ath6kl_connectservice(struct ath6kl *ar,
 
 	status = htc_conn_service(ar->htc_target, con_req, &response);
 	if (status) {
-		ath6kl_err("%s: failed to connect to %s service status:%d\n",
-				__func__, desc, status);
+		ath6kl_err("failed to connect to %s service status:%d\n",
+			   desc, status);
 		return status;
 	}
 
@@ -186,8 +186,7 @@ static int ath6kl_connectservice(struct ath6kl *ar,
 		set_ac2_ep_map(ar, WMM_AC_VO, response.endpoint);
 		break;
 	default:
-		ath6kl_err("%s: service id is not mapped %d\n",
-			__func__, con_req->svc_id);
+		ath6kl_err("service id is not mapped %d\n", con_req->svc_id);
 		return -EINVAL;
 	}
 
@@ -330,8 +329,7 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
 			(u8 *)&blk_size,
 			4);
 	if (status) {
-		ath6kl_err("%s: bmi_write_memory for IO block size failed\n",
-			   __func__);
+		ath6kl_err("bmi_write_memory for IO block size failed\n");
 		goto out;
 	}
 
@@ -347,8 +345,7 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
 				(u8 *)&mbox_isr_yield_val,
 				4);
 		if (status) {
-			ath6kl_err("%s: bmi_write_memory for yield limit failed\n",
-				   __func__);
+			ath6kl_err("bmi_write_memory for yield limit failed\n");
 			goto out;
 		}
 	}
@@ -379,8 +376,7 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
 	status = ath6kl_read_reg_diag(ar, &address, &regdump_loc);
 
 	if (status || !regdump_loc) {
-		ath6kl_err("%s: failed to get ptr to register dump area\n",
-			__func__);
+		ath6kl_err("failed to get ptr to register dump area\n");
 		return;
 	}
 
@@ -410,7 +406,7 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
 
 void ath6kl_target_failure(struct ath6kl *ar)
 {
-	ath6kl_err("%s: target asserted\n", __func__);
+	ath6kl_err("target asserted\n");
 
 	/* try dumping target assertion information (if any) */
 	ath6kl_dump_target_assert_info(ar);
@@ -428,44 +424,39 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar)
 	 */
 	if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi,
 					       ar->rx_meta_ver, 0, 0)) {
-		ath6kl_err("%s: unable to set the rx frame format\n", __func__);
+		ath6kl_err("unable to set the rx frame format\n");
 		status = -EIO;
 	}
 
 	if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN)
 		if ((ath6kl_wmi_pmparams_cmd(ar->wmi, 0, 1, 0, 0, 1,
 		     IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
-			ath6kl_err("%s: unable to set power save fail event policy\n",
-				   __func__);
+			ath6kl_err("unable to set power save fail event policy\n");
 			status = -EIO;
 		}
 
 	if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER))
 		if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, 0,
 		     WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) {
-			ath6kl_err("%s: unable to set barker preamble policy\n",
-				   __func__);
+			ath6kl_err("unable to set barker preamble policy\n");
 			status = -EIO;
 		}
 
 	if (ath6kl_wmi_set_keepalive_cmd(ar->wmi,
 			WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) {
-		ath6kl_err("%s: unable to set keep alive interval\n",
-			   __func__);
+		ath6kl_err("unable to set keep alive interval\n");
 		status = -EIO;
 	}
 
 	if (ath6kl_wmi_disctimeout_cmd(ar->wmi,
 			WLAN_CONFIG_DISCONNECT_TIMEOUT)) {
-		ath6kl_err("%s: unable to set disconnect timeout\n",
-			   __func__);
+		ath6kl_err("unable to set disconnect timeout\n");
 		status = -EIO;
 	}
 
 	if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST))
 		if (ath6kl_wmi_set_wmm_txop(ar->wmi, WMI_TXOP_DISABLED)) {
-			ath6kl_err("%s: unable to set txop bursting\n",
-				   __func__);
+			ath6kl_err("unable to set txop bursting\n");
 			status = -EIO;
 		}
 
@@ -487,8 +478,7 @@ int ath6kl_configure_target(struct ath6kl *ar)
 			     ath6kl_get_hi_item_addr(ar,
 			     HI_ITEM(hi_app_host_interest)),
 			     (u8 *)&param, 4) != 0) {
-		ath6kl_err("%s: bmi_write_memory for htc version failed\n",
-			__func__);
+		ath6kl_err("bmi_write_memory for htc version failed\n");
 		return -EIO;
 	}
 
@@ -499,8 +489,7 @@ int ath6kl_configure_target(struct ath6kl *ar)
 			    ath6kl_get_hi_item_addr(ar,
 			    HI_ITEM(hi_option_flag)),
 			    (u8 *)&param, 4) != 0) {
-		ath6kl_err("%s: bmi_read_memory for setting fwmode failed\n",
-			__func__);
+		ath6kl_err("bmi_read_memory for setting fwmode failed\n");
 		return -EIO;
 	}
 
@@ -514,8 +503,7 @@ int ath6kl_configure_target(struct ath6kl *ar)
 			     HI_ITEM(hi_option_flag)),
 			     (u8 *)&param,
 			     4) != 0) {
-		ath6kl_err("%s: bmi_write_memory for setting fwmode failed\n",
-			__func__);
+		ath6kl_err("bmi_write_memory for setting fwmode failed\n");
 		return -EIO;
 	}
 
@@ -543,16 +531,14 @@ int ath6kl_configure_target(struct ath6kl *ar)
 				     ath6kl_get_hi_item_addr(ar,
 				     HI_ITEM(hi_board_ext_data)),
 				     (u8 *)&param, 4) != 0) {
-			ath6kl_err("%s: bmi_write_memory for hi_board_ext_data failed\n",
-				   __func__);
+			ath6kl_err("bmi_write_memory for hi_board_ext_data failed\n");
 			return -EIO;
 		}
 		if (ath6kl_bmi_write(ar,
 				     ath6kl_get_hi_item_addr(ar,
 				     HI_ITEM(hi_end_ram_reserve_sz)),
 				     (u8 *)&ram_reserved_size, 4) != 0) {
-			ath6kl_err("%s: bmi_write_memory for hi_end_ram_reserve_sz failed\n",
-				   __func__);
+			ath6kl_err("bmi_write_memory for hi_end_ram_reserve_sz failed\n");
 			return -EIO;
 		}
 	}
@@ -573,7 +559,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *sdev)
 
 	wdev = ath6kl_cfg80211_init(sdev);
 	if (!wdev) {
-		ath6kl_err("%s: ath6kl_cfg80211_init failed\n", __func__);
+		ath6kl_err("ath6kl_cfg80211_init failed\n");
 		return NULL;
 	}
 
@@ -584,8 +570,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *sdev)
 
 	dev = alloc_netdev(0, "wlan%d", ether_setup);
 	if (!dev) {
-		ath6kl_err("%s: no memory for network device instance\n",
-			__func__);
+		ath6kl_err("no memory for network device instance\n");
 		ath6kl_cfg80211_deinit(ar);
 		return NULL;
 	}
@@ -985,8 +970,7 @@ static int ath6kl_init_upload(struct ath6kl *ar)
 
 	/* WAR to avoid SDIO CRC err */
 	if (ar->version.target_ver == AR6003_REV2_VERSION) {
-		ath6kl_err("%s: temporary war to avoid sdio crc error\n",
-			   __func__);
+		ath6kl_err("temporary war to avoid sdio crc error\n");
 
 		param = 0x20;
 
@@ -1071,7 +1055,7 @@ static int ath6kl_init(struct net_device *dev)
 	set_bit(WMI_ENABLED, &ar->flag);
 	ar->wmi = ath6kl_wmi_init((void *) ar);
 	if (!ar->wmi) {
-		ath6kl_err("%s: failed to initialize wmi\n", __func__);
+		ath6kl_err("failed to initialize wmi\n");
 		status = -EIO;
 		goto ath6kl_init_done;
 	}
@@ -1126,16 +1110,14 @@ static int ath6kl_init(struct net_device *dev)
 						    WMI_TIMEOUT);
 
 	if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {
-		ath6kl_err("%s: abi version mismatch: host(0x%x), target(0x%x)\n",
-			   __func__, ATH6KL_ABI_VERSION,
-			   ar->version.abi_ver);
+		ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n",
+			   ATH6KL_ABI_VERSION, ar->version.abi_ver);
 		status = -EIO;
 		goto err_htc_stop;
 	}
 
 	if (!timeleft || signal_pending(current)) {
-		ath6kl_err("%s: wmi is not ready or wait was interrupted\n",
-			   __func__);
+		ath6kl_err("wmi is not ready or wait was interrupted\n");
 		status = -EIO;
 		goto err_htc_stop;
 	}
@@ -1144,7 +1126,7 @@ static int ath6kl_init(struct net_device *dev)
 
 	/* communicate the wmi protocol verision to the target */
 	if ((ath6kl_set_host_app_area(ar)) != 0)
-		ath6kl_err("%s: unable to set the host app area\n", __func__);
+		ath6kl_err("unable to set the host app area\n");
 
 	ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
 			 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
@@ -1203,7 +1185,7 @@ int ath6kl_core_init(struct ath6kl *ar)
 
 	ar->aggr_cntxt = aggr_init(ar->net_dev);
 	if (!ar->aggr_cntxt) {
-		ath6kl_err("%s: failed to initialize aggr.\n", __func__);
+		ath6kl_err("failed to initialize aggr\n");
 		ret = -ENOMEM;
 		goto err_htc_cleanup;
 	}
@@ -1219,7 +1201,7 @@ int ath6kl_core_init(struct ath6kl *ar)
 	/* This runs the init function if registered */
 	ret = register_netdev(ar->net_dev);
 	if (ret) {
-		ath6kl_err("%s: register_netdev failed\n", __func__);
+		ath6kl_err("register_netdev failed\n");
 		ath6kl_destroy(ar->net_dev, 0);
 		return ret;
 	}
@@ -1250,7 +1232,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar)
 	set_bit(DESTROY_IN_PROGRESS, &ar->flag);
 
 	if (down_interruptible(&ar->sem)) {
-		ath6kl_err("%s: down_interruptible failed\n", __func__);
+		ath6kl_err("down_interruptible failed\n");
 		return;
 	}
 
@@ -1281,7 +1263,7 @@ void ath6kl_destroy(struct net_device *dev, unsigned int unregister)
 	struct ath6kl *ar;
 
 	if (!dev || !ath6kl_priv(dev)) {
-		ath6kl_err("%s: failed to get device structure\n", __func__);
+		ath6kl_err("failed to get device structure\n");
 		return;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index ec07888..f325a23 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -204,8 +204,8 @@ static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
 	}
 
 	if (status) {
-		ath6kl_err("%s: failed to write initial bytes of 0x%x to window reg: 0x%X\n",
-			   __func__, addr, reg_addr);
+		ath6kl_err("failed to write initial bytes of 0x%x to window reg: 0x%X\n",
+			   addr, reg_addr);
 		return status;
 	}
 
@@ -219,8 +219,8 @@ static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
 				     4, HIF_WR_SYNC_BYTE_INC);
 
 	if (status) {
-		ath6kl_err("%s: failed to write 0x%x to window reg: 0x%X\n",
-			   __func__, addr, reg_addr);
+		ath6kl_err("failed to write 0x%x to window reg: 0x%X\n",
+			   addr, reg_addr);
 		return status;
 	}
 
@@ -246,8 +246,7 @@ int ath6kl_read_reg_diag(struct ath6kl *ar, u32 *address, u32 *data)
 	status = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *)data,
 				     sizeof(u32), HIF_RD_SYNC_BYTE_INC);
 	if (status) {
-		ath6kl_err("%s: failed to read from window data addr\n",
-			__func__);
+		ath6kl_err("failed to read from window data addr\n");
 		return status;
 	}
 
@@ -267,8 +266,7 @@ static int ath6kl_write_reg_diag(struct ath6kl *ar, u32 *address, u32 *data)
 	status = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *)data,
 				     sizeof(u32), HIF_WR_SYNC_BYTE_INC);
 	if (status) {
-		ath6kl_err("%s: failed to write 0x%x to window data addr\n",
-			   __func__, *data);
+		ath6kl_err("failed to write 0x%x to window data addr\n", *data);
 		return status;
 	}
 
@@ -316,7 +314,7 @@ static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
 	status = ath6kl_write_reg_diag(ar, &address, &data);
 
 	if (status)
-		ath6kl_err("%s: failed to reset target\n", __func__);
+		ath6kl_err("failed to reset target\n");
 }
 
 void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile,
diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c
index 1125b37..615b46d 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -194,8 +194,8 @@ int ath6kl_control_tx(void *devt, struct sk_buff *skb,
 		 * are just going to drop this packet.
 		 */
 		cookie = NULL;
-		ath6kl_err("%s: wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n",
-			   __func__, skb, skb->len);
+		ath6kl_err("wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n",
+			   skb, skb->len);
 	} else
 		cookie = ath6kl_alloc_cookie(ar);
 
@@ -270,14 +270,13 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
 		}
 
 		if (ath6kl_wmi_dix_2_dot3(ar->wmi, skb)) {
-			ath6kl_err("%s: ath6kl_wmi_dix_2_dot3 failed\n",
-				   __func__);
+			ath6kl_err("ath6kl_wmi_dix_2_dot3 failed\n");
 			goto fail_tx;
 		}
 
 		if (ath6kl_wmi_data_hdr_add(ar->wmi, skb, DATA_MSGTYPE,
 					    more_data, 0, 0, NULL)) {
-			ath6kl_err("%s: wmi_data_hdr_add failed\n", __func__);
+			ath6kl_err("wmi_data_hdr_add failed\n");
 			goto fail_tx;
 		}
 
@@ -302,7 +301,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
 		eid = ar->ac2ep_map[ac];
 
 	if (eid == 0 || eid == ENDPOINT_UNUSED) {
-		ath6kl_err("%s: eid %d is not mapped!\n", __func__, eid);
+		ath6kl_err("eid %d is not mapped!\n", eid);
 		spin_unlock_bh(&ar->lock);
 		goto fail_tx;
 	}
@@ -423,7 +422,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
 		spin_lock_bh(&ar->lock);
 		set_bit(WMI_CTRL_EP_FULL, &ar->flag);
 		spin_unlock_bh(&ar->lock);
-		ath6kl_err("%s: wmi ctrl ep is full\n", __func__);
+		ath6kl_err("wmi ctrl ep is full\n");
 		return HTC_SEND_FULL_KEEP;
 	}
 
@@ -562,8 +561,7 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue)
 			ar->net_stats.tx_errors++;
 
 			if (status != -ENOSPC)
-				ath6kl_err("%s: tx error, status: 0x%x\n",
-					   __func__, status);
+				ath6kl_err("tx error, status: 0x%x\n", status);
 			ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
 				   "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n",
 				   __func__, skb, packet->buf, packet->act_len,
@@ -644,7 +642,7 @@ static void ath6kl_alloc_netbufs(struct sk_buff_head *q, u16 num)
 	while (num) {
 		skb = ath6kl_buf_alloc(ATH6KL_BUFFER_SIZE);
 		if (!skb) {
-			ath6kl_err("%s: netbuf allocation failed\n", __func__);
+			ath6kl_err("netbuf allocation failed\n");
 			return;
 		}
 		skb_queue_tail(q, skb);
@@ -785,22 +783,22 @@ static void aggr_slice_amsdu(struct aggr_info *p_aggr,
 
 		if (payload_8023_len < MIN_MSDU_SUBFRAME_PAYLOAD_LEN ||
 		    payload_8023_len > MAX_MSDU_SUBFRAME_PAYLOAD_LEN) {
-			ath6kl_err("%s: 802.3 AMSDU frame bound check failed. len %d\n",
-				   __func__, payload_8023_len);
+			ath6kl_err("802.3 AMSDU frame bound check failed. len %d\n",
+				   payload_8023_len);
 			break;
 		}
 
 		frame_8023_len = payload_8023_len + mac_hdr_len;
 		new_skb = aggr_get_free_skb(p_aggr);
 		if (!new_skb) {
-			ath6kl_err("%s: no buffer available\n", __func__);
+			ath6kl_err("no buffer available\n");
 			break;
 		}
 
 		memcpy(new_skb->data, framep, frame_8023_len);
 		skb_put(new_skb, frame_8023_len);
 		if (ath6kl_wmi_dot3_2_dix(new_skb)) {
-			ath6kl_err("%s: dot3_2_dix error\n", __func__);
+			ath6kl_err("dot3_2_dix error\n");
 			dev_kfree_skb(new_skb);
 			break;
 		}
@@ -1080,10 +1078,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet)
 	 */
 	if (ar->nw_type != AP_NETWORK &&
 	    ((packet->act_len < min_hdr_len) ||
-	     (packet->act_len >
-	      WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) {
-		ath6kl_info("%s: frame len is too short or too long\n",
-			    __func__);
+	     (packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) {
+		ath6kl_info("frame len is too short or too long\n");
 		ar->net_stats.rx_errors++;
 		ar->net_stats.rx_length_errors++;
 		dev_kfree_skb(skb);
@@ -1255,8 +1251,8 @@ static void aggr_timeout(unsigned long arg)
 			continue;
 
 		stats->num_timeouts++;
-		ath6kl_err("%s: aggr timeout (st %d end %d)\n",
-			   __func__, rxtid->seq_next,
+		ath6kl_err("aggr timeout (st %d end %d)\n",
+			   rxtid->seq_next,
 			   ((rxtid->seq_next + rxtid->hold_q_sz-1) &
 			    ATH6KL_MAX_SEQ_NO));
 		aggr_deque_frms(p_aggr, i, 0, 0);
@@ -1356,8 +1352,7 @@ struct aggr_info *aggr_init(struct net_device *dev)
 
 	p_aggr = kzalloc(sizeof(struct aggr_info), GFP_KERNEL);
 	if (!p_aggr) {
-		ath6kl_err("%s: failed to alloc memory for aggr_node\n",
-			   __func__);
+		ath6kl_err("failed to alloc memory for aggr_node\n");
 		return NULL;
 	}
 
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index 5d95b56..a52d7d2 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -1373,7 +1373,7 @@ static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
 
 	ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
 	if (ret) {
-		ath6kl_err("%s: unable to configure snr threshold\n", __func__);
+		ath6kl_err("unable to configure snr threshold\n");
 		return -EIO;
 	}
 
@@ -2490,7 +2490,7 @@ static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
 	int ret = 0;
 
 	if (skb->len < sizeof(struct wmix_cmd_hdr)) {
-		ath6kl_err("%s: bad packet 1\n", __func__);
+		ath6kl_err("bad packet 1\n");
 		wmi->stat.cmd_len_err++;
 		return -EINVAL;
 	}
@@ -2509,7 +2509,7 @@ static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
 	case WMIX_DBGLOG_EVENTID:
 		break;
 	default:
-		ath6kl_err("%s: unknown cmd id 0x%x\n", __func__, id);
+		ath6kl_err("unknown cmd id 0x%x\n", id);
 		wmi->stat.cmd_id_err++;
 		ret = -EINVAL;
 		break;
@@ -2531,7 +2531,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
 		return -EINVAL;
 
 	if (skb->len < sizeof(struct wmi_cmd_hdr)) {
-		ath6kl_err("%s: bad packet 1\n", __func__);
+		ath6kl_err("bad packet 1\n");
 		dev_kfree_skb(skb);
 		wmi->stat.cmd_len_err++;
 		return -EINVAL;
-- 
1.7.6.131.g99019

^ permalink raw reply related

* [PATCH 3/3] ath6kl: cfg80211: Add and use ath6kl_cfg80211_ready helper
From: Joe Perches @ 2011-07-17 18:43 UTC (permalink / raw)
  To: Kalle Valo, linux-kernel
  Cc: devel, gregkh, error27, John W. Linville, linux-wireless, netdev
In-Reply-To: <cover.1310927985.git.joe@perches.com>

Reduce code duplication by using a helper function to
check if the device is ready.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c |  150 ++++++----------------------
 1 files changed, 30 insertions(+), 120 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 34df184..71515bb 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -217,6 +217,21 @@ static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt)
 	}
 }
 
+static bool ath6kl_cfg80211_ready(struct ath6kl *ar)
+{
+	if (!test_bit(WMI_READY, &ar->flag)) {
+		ath6kl_err("wmi is not ready\n");
+		return false;
+	}
+
+	if (ar->wlan_state == WLAN_DISABLED) {
+		ath6kl_err("wlan disabled\n");
+		return false;
+	}
+
+	return true;
+}
+
 static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 				   struct cfg80211_connect_params *sme)
 {
@@ -225,15 +240,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
 	ar->sme_state = SME_CONNECTING;
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready yet\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
-		return -EIO;
-	}
 
 	if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) {
 		ath6kl_err("destroy in progress\n");
@@ -575,15 +583,8 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: reason=%u\n", __func__,
 		   reason_code);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) {
 		ath6kl_err("busy, destroy in progress\n");
@@ -781,15 +782,8 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
 	int ret = 0;
 	u32 force_fg_scan = 0;
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
-		return -EIO;
-	}
 
 	if (!ar->usr_bss_filter) {
 		if (ath6kl_wmi_bssfilter_cmd(ar->wmi,
@@ -866,15 +860,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
 	u8 key_type;
 	int status = 0;
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
@@ -951,15 +938,8 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
@@ -991,15 +971,8 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
@@ -1033,15 +1006,8 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
@@ -1081,15 +1047,8 @@ static int ath6kl_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
-		return -EIO;
-	}
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: not supported\n", __func__);
 	return -ENOTSUPP;
@@ -1115,15 +1074,8 @@ static int ath6kl_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: changed 0x%x\n", __func__,
 		   changed);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
 		ret = ath6kl_wmi_set_rts_cmd(ar->wmi, wiphy->rts_threshold);
@@ -1150,15 +1102,8 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type 0x%x, dbm %d\n", __func__,
 		   type, dbm);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	switch (type) {
 	case NL80211_TX_POWER_AUTOMATIC:
@@ -1181,15 +1126,8 @@ static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
 {
 	struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (test_bit(CONNECTED, &ar->flag)) {
 		ar->tx_pwr = 0;
@@ -1222,15 +1160,8 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: pmgmt %d, timeout %d\n",
 		   __func__, pmgmt, timeout);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (pmgmt) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: max perf\n", __func__);
@@ -1258,15 +1189,8 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy,
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type %u\n", __func__, type);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	switch (type) {
 	case NL80211_IFTYPE_STATION:
@@ -1292,15 +1216,8 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy,
 	struct ath6kl *ar = ath6kl_priv(dev);
 	int status;
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	if (!ibss_param->ssid_len ||
 	    IEEE80211_MAX_SSID_LEN < ibss_param->ssid_len) {
@@ -1367,15 +1284,8 @@ static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy,
 {
 	struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(dev);
 
-	if (!test_bit(WMI_READY, &ar->flag)) {
-		ath6kl_err("wmi is not ready\n");
-		return -EIO;
-	}
-
-	if (ar->wlan_state == WLAN_DISABLED) {
-		ath6kl_err("wlan disabled\n");
+	if (!ath6kl_cfg80211_ready(ar))
 		return -EIO;
-	}
 
 	ath6kl_disconnect(ar);
 	memset(ar->ssid, 0, sizeof(ar->ssid));
-- 
1.7.6.131.g99019


^ permalink raw reply related

* [PATCH] net: vlan, qlcnic: make vlan_find_dev private
From: David Lamparter @ 2011-07-17 18:53 UTC (permalink / raw)
  To: netdev
  Cc: David Lamparter, Patrick McHardy, Amit Kumar Salecha,
	Anirban Chakraborty, linux-driver

there is only one user of vlan_find_dev outside of the actual vlan code:
qlcnic uses it to iterate over some VLANs it knows.

let's just make vlan_find_dev private to the VLAN code and have the
iteration in qlcnic be a bit more direct. (a few rcu dereferences less
too)

Signed-off-by: David Lamparter <equinox@diac24.net>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Amit Kumar Salecha <amit.salecha@qlogic.com>
Cc: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Cc: linux-driver@qlogic.com
---
 drivers/net/qlcnic/qlcnic_main.c |    7 ++++++-
 include/linux/if_vlan.h          |   11 -----------
 net/8021q/vlan.h                 |   12 ++++++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 006a693..3579229 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -4198,13 +4198,18 @@ static void
 qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
+	struct vlan_group *grp;
 	struct net_device *dev;
 	u16 vid;
 
 	qlcnic_config_indev_addr(adapter, netdev, event);
 
+	grp = rcu_dereference_rtnl(netdev->vlgrp);
+	if (!grp)
+		return;
+
 	for_each_set_bit(vid, adapter->vlans, VLAN_N_VID) {
-		dev = vlan_find_dev(netdev, vid);
+		dev = vlan_group_get_device(grp, vid);
 		if (!dev)
 			continue;
 		qlcnic_config_indev_addr(adapter, dev, event);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index affa273..bc03e40 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -119,17 +119,6 @@ static inline int is_vlan_dev(struct net_device *dev)
 #define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-/* Must be invoked with rcu_read_lock or with RTNL. */
-static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
-					       u16 vlan_id)
-{
-	struct vlan_group *grp = rcu_dereference_rtnl(real_dev->vlgrp);
-
-	if (grp)
-		return vlan_group_get_device(grp, vlan_id);
-
-	return NULL;
-}
 
 extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
 extern u16 vlan_dev_vlan_id(const struct net_device *dev);
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 9da07e3..b132f54 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -74,6 +74,18 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
 	return netdev_priv(dev);
 }
 
+/* Must be invoked with rcu_read_lock or with RTNL. */
+static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
+					       u16 vlan_id)
+{
+	struct vlan_group *grp = rcu_dereference_rtnl(real_dev->vlgrp);
+
+	if (grp)
+		return vlan_group_get_device(grp, vlan_id);
+
+	return NULL;
+}
+
 /* found in vlan_dev.c */
 void vlan_dev_set_ingress_priority(const struct net_device *dev,
 				   u32 skb_prio, u16 vlan_prio);
-- 
1.7.5.3


^ permalink raw reply related

* Re: [PATCH 0/3] ath6kl: neatening
From: Kalle Valo @ 2011-07-17 18:56 UTC (permalink / raw)
  To: Joe Perches; +Cc: devel, gregkh, error27, linux-kernel, linux-wireless, netdev
In-Reply-To: <cover.1310927985.git.joe@perches.com>

On 07/17/2011 09:43 PM, Joe Perches wrote:
> Joe Perches (3):
>   ath6kl: Add missing newlines and coalesce messages
>   ath6kl: Remove __func__ uses from ath6kl_err
>   ath6kl: cfg80211: Add and use ath6kl_cfg80211_ready helper

Nice, thanks a lot. I'm planning to send v3 of athk6kl patches later
today. Is it okay for you if I amend your three patches to that patchset?

Kalle

^ permalink raw reply

* [PATCH 0/5] More neigh simplifications.
From: David Miller @ 2011-07-17 19:29 UTC (permalink / raw)
  To: netdev


Add helpers for duplicate copies of code.

Eliminate superfluous ops methods that always get set to
the same exact function.

Get rid of hh->hh_output method.

I guess the indirection removal is a non-trivial improvement because
these changes knock a full 2 seconds off of my udpflood tests. :-)

Signed-off-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* [PATCH 1/5] net: Create and use new helper, neigh_output().
From: David Miller @ 2011-07-17 19:30 UTC (permalink / raw)
  To: netdev


Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/net/neighbour.h |    9 +++++++++
 net/ipv4/ip_output.c    |   10 +++-------
 net/ipv6/ip6_output.c   |   10 +++-------
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index bd8f9f0..337da24 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -344,6 +344,15 @@ static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
 	return hh->hh_output(skb);
 }
 
+static inline int neigh_output(struct neighbour *n, struct sk_buff *skb)
+{
+	struct hh_cache *hh = &n->hh;
+	if (hh->hh_len)
+		return neigh_hh_output(hh, skb);
+	else
+		return n->output(skb);
+}
+
 static inline struct neighbour *
 __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat)
 {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1ac674a..db296a9 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -205,13 +205,9 @@ static inline int ip_finish_output2(struct sk_buff *skb)
 	}
 
 	neigh = dst->neighbour;
-	if (neigh) {
-		struct hh_cache *hh = &neigh->hh;
-		if (hh->hh_len)
-			return neigh_hh_output(hh, skb);
-		else
-			return neigh->output(skb);
-	}
+	if (neigh)
+		return neigh_output(neigh, skb);
+
 	if (net_ratelimit())
 		printk(KERN_DEBUG "ip_finish_output2: No header cache and no neighbour!\n");
 	kfree_skb(skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 36362e9..eb50bb0 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -136,13 +136,9 @@ static int ip6_finish_output2(struct sk_buff *skb)
 	}
 
 	neigh = dst->neighbour;
-	if (neigh) {
-		struct hh_cache *hh = &neigh->hh;
-		if (hh->hh_len)
-			return neigh_hh_output(hh, skb);
-		else
-			return neigh->output(skb);
-	}
+	if (neigh)
+		return neigh_output(neigh, skb);
+
 	IP6_INC_STATS_BH(dev_net(dst->dev),
 			 ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
 	kfree_skb(skb);
-- 
1.7.6


^ permalink raw reply related

* [PATCH 2/5] neigh: Simply destroy handling wrt. hh_cache.
From: David Miller @ 2011-07-17 19:30 UTC (permalink / raw)
  To: netdev


Now that hh_cache entries are embedded inside of neighbour
entries, their lifetimes and accesses are now synchronous
to that of the encompassing neighbour object.

Therefore we don't need to hook up the blackhole op to
hh_output on destroy.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/core/neighbour.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 77a399f..83f9998 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -689,8 +689,6 @@ static void neigh_destroy_rcu(struct rcu_head *head)
  */
 void neigh_destroy(struct neighbour *neigh)
 {
-	struct hh_cache *hh;
-
 	NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
 
 	if (!neigh->dead) {
@@ -703,13 +701,6 @@ void neigh_destroy(struct neighbour *neigh)
 	if (neigh_del_timer(neigh))
 		printk(KERN_WARNING "Impossible event.\n");
 
-	hh = &neigh->hh;
-	if (hh->hh_len) {
-		write_seqlock_bh(&hh->hh_lock);
-		hh->hh_output = neigh_blackhole;
-		write_sequnlock_bh(&hh->hh_lock);
-	}
-
 	skb_queue_purge(&neigh->arp_queue);
 
 	dev_put(neigh->dev);
-- 
1.7.6


^ permalink raw reply related

* [PATCH 3/5] neigh: Kill neigh_ops->hh_output
From: David Miller @ 2011-07-17 19:30 UTC (permalink / raw)
  To: netdev


It's always dev_queue_xmit().

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/net/neighbour.h |    1 -
 net/atm/clip.c          |    1 -
 net/core/neighbour.c    |    4 ++--
 net/decnet/dn_neigh.c   |    3 ---
 net/ipv4/arp.c          |    4 ----
 net/ipv6/ndisc.c        |    3 ---
 6 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 337da24..97990dd 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -122,7 +122,6 @@ struct neigh_ops {
 	void			(*error_report)(struct neighbour *, struct sk_buff*);
 	int			(*output)(struct sk_buff*);
 	int			(*connected_output)(struct sk_buff*);
-	int			(*hh_output)(struct sk_buff*);
 	int			(*queue_xmit)(struct sk_buff*);
 };
 
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 1d4be60..036cd43 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -273,7 +273,6 @@ static const struct neigh_ops clip_neigh_ops = {
 	.error_report =		clip_neigh_error,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 83f9998..c22def5 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -746,7 +746,7 @@ static void neigh_connect(struct neighbour *neigh)
 
 	hh = &neigh->hh;
 	if (hh->hh_len)
-		hh->hh_output = neigh->ops->hh_output;
+		hh->hh_output = dev_queue_xmit;
 }
 
 static void neigh_periodic_work(struct work_struct *work)
@@ -1222,7 +1222,7 @@ static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst)
 		goto end;
 
 	if (n->nud_state & NUD_CONNECTED)
-		hh->hh_output = n->ops->hh_output;
+		hh->hh_output = dev_queue_xmit;
 	else
 		hh->hh_output = n->ops->output;
 
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
index 03eb226..abf4de8 100644
--- a/net/decnet/dn_neigh.c
+++ b/net/decnet/dn_neigh.c
@@ -64,7 +64,6 @@ static const struct neigh_ops dn_long_ops = {
 	.error_report =		dn_long_error_report,
 	.output =		dn_long_output,
 	.connected_output =	dn_long_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -76,7 +75,6 @@ static const struct neigh_ops dn_short_ops = {
 	.error_report =		dn_short_error_report,
 	.output =		dn_short_output,
 	.connected_output =	dn_short_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -88,7 +86,6 @@ static const struct neigh_ops dn_phase3_ops = {
 	.error_report =		dn_short_error_report, /* Can use short version here */
 	.output =		dn_phase3_output,
 	.connected_output =	dn_phase3_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit
 };
 
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3e55456..f5f0aa1 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -138,7 +138,6 @@ static const struct neigh_ops arp_generic_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_connected_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -148,7 +147,6 @@ static const struct neigh_ops arp_hh_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_resolve_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -156,7 +154,6 @@ static const struct neigh_ops arp_direct_ops = {
 	.family =		AF_INET,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -166,7 +163,6 @@ static const struct neigh_ops arp_broken_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_compat_output,
 	.connected_output =	neigh_compat_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 7596f07..db782d2 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -107,7 +107,6 @@ static const struct neigh_ops ndisc_generic_ops = {
 	.error_report =		ndisc_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_connected_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -117,7 +116,6 @@ static const struct neigh_ops ndisc_hh_ops = {
 	.error_report =		ndisc_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_resolve_output,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
@@ -126,7 +124,6 @@ static const struct neigh_ops ndisc_direct_ops = {
 	.family =		AF_INET6,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.hh_output =		dev_queue_xmit,
 	.queue_xmit =		dev_queue_xmit,
 };
 
-- 
1.7.6


^ permalink raw reply related

* [PATCH 4/5] neigh: Kill hh_cache->hh_output
From: David Miller @ 2011-07-17 19:30 UTC (permalink / raw)
  To: netdev


It's just taking on one of two possible values, either
neigh_ops->output or dev_queue_xmit().  And this is purely depending
upon whether nud_state has NUD_CONNECTED set or not.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/linux/netdevice.h |    1 -
 include/net/neighbour.h   |    4 ++--
 net/core/neighbour.c      |   25 ++-----------------------
 net/ipv4/route.c          |    6 +++---
 4 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f84dfd2..52c4e38 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -254,7 +254,6 @@ struct netdev_hw_addr_list {
 struct hh_cache {
 	u16		hh_len;
 	u16		__pad;
-	int		(*hh_output)(struct sk_buff *skb);
 	seqlock_t	hh_lock;
 
 	/* cached hardware header; allow for machine alignment needs.        */
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 97990dd..60bac81 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -340,13 +340,13 @@ static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
 	} while (read_seqretry(&hh->hh_lock, seq));
 
 	skb_push(skb, hh_len);
-	return hh->hh_output(skb);
+	return dev_queue_xmit(skb);
 }
 
 static inline int neigh_output(struct neighbour *n, struct sk_buff *skb)
 {
 	struct hh_cache *hh = &n->hh;
-	if (hh->hh_len)
+	if ((n->nud_state & NUD_CONNECTED) && hh->hh_len)
 		return neigh_hh_output(hh, skb);
 	else
 		return n->output(skb);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index c22def5..2feda6e7 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -720,15 +720,9 @@ EXPORT_SYMBOL(neigh_destroy);
  */
 static void neigh_suspect(struct neighbour *neigh)
 {
-	struct hh_cache *hh;
-
 	NEIGH_PRINTK2("neigh %p is suspected.\n", neigh);
 
 	neigh->output = neigh->ops->output;
-
-	hh = &neigh->hh;
-	if (hh->hh_len)
-		hh->hh_output = neigh->ops->output;
 }
 
 /* Neighbour state is OK;
@@ -738,15 +732,9 @@ static void neigh_suspect(struct neighbour *neigh)
  */
 static void neigh_connect(struct neighbour *neigh)
 {
-	struct hh_cache *hh;
-
 	NEIGH_PRINTK2("neigh %p is connected.\n", neigh);
 
 	neigh->output = neigh->ops->connected_output;
-
-	hh = &neigh->hh;
-	if (hh->hh_len)
-		hh->hh_output = dev_queue_xmit;
 }
 
 static void neigh_periodic_work(struct work_struct *work)
@@ -1215,18 +1203,9 @@ static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst)
 	/* Only one thread can come in here and initialize the
 	 * hh_cache entry.
 	 */
-	if (hh->hh_len)
-		goto end;
-
-	if (dev->header_ops->cache(n, hh, prot))
-		goto end;
-
-	if (n->nud_state & NUD_CONNECTED)
-		hh->hh_output = dev_queue_xmit;
-	else
-		hh->hh_output = n->ops->output;
+	if (!hh->hh_len)
+		dev->header_ops->cache(n, hh, prot);
 
-end:
 	write_unlock_bh(&n->lock);
 }
 
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a52bb74..bcf9bb5 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -427,9 +427,9 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
 			      dst_metric(&r->dst, RTAX_RTTVAR)),
 			r->rt_key_tos,
 			-1,
-			(r->dst.neighbour ?
-			 (r->dst.neighbour->hh.hh_output ==
-			  dev_queue_xmit) : 0),
+			(r->dst.neighbour &&
+			 (r->dst.neighbour->nud_state & NUD_CONNECTED)) ?
+			   1 : 0,
 			r->rt_spec_dst, &len);
 
 		seq_printf(seq, "%*s\n", 127 - len, "");
-- 
1.7.6


^ permalink raw reply related

* [PATCH 5/5] neigh: Kill ndisc_ops->queue_xmit
From: David Miller @ 2011-07-17 19:30 UTC (permalink / raw)
  To: netdev


It is always dev_queue_xmit().

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/net/neighbour.h |    1 -
 net/atm/clip.c          |    1 -
 net/core/neighbour.c    |    4 ++--
 net/decnet/dn_neigh.c   |    5 +----
 net/ipv4/arp.c          |    6 +-----
 net/ipv6/ndisc.c        |    5 +----
 6 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 60bac81..334e92f 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -122,7 +122,6 @@ struct neigh_ops {
 	void			(*error_report)(struct neighbour *, struct sk_buff*);
 	int			(*output)(struct sk_buff*);
 	int			(*connected_output)(struct sk_buff*);
-	int			(*queue_xmit)(struct sk_buff*);
 };
 
 struct pneigh_entry {
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 036cd43..40d7368 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -273,7 +273,6 @@ static const struct neigh_ops clip_neigh_ops = {
 	.error_report =		clip_neigh_error,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 static int clip_constructor(struct neighbour *neigh)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 2feda6e7..b031cf6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1257,7 +1257,7 @@ int neigh_resolve_output(struct sk_buff *skb)
 		} while (read_seqretry(&neigh->ha_lock, seq));
 
 		if (err >= 0)
-			rc = neigh->ops->queue_xmit(skb);
+			rc = dev_queue_xmit(skb);
 		else
 			goto out_kfree_skb;
 	}
@@ -1292,7 +1292,7 @@ int neigh_connected_output(struct sk_buff *skb)
 	} while (read_seqretry(&neigh->ha_lock, seq));
 
 	if (err >= 0)
-		err = neigh->ops->queue_xmit(skb);
+		err = dev_queue_xmit(skb);
 	else {
 		err = -EINVAL;
 		kfree_skb(skb);
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
index abf4de8..84fee8a 100644
--- a/net/decnet/dn_neigh.c
+++ b/net/decnet/dn_neigh.c
@@ -64,7 +64,6 @@ static const struct neigh_ops dn_long_ops = {
 	.error_report =		dn_long_error_report,
 	.output =		dn_long_output,
 	.connected_output =	dn_long_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 /*
@@ -75,7 +74,6 @@ static const struct neigh_ops dn_short_ops = {
 	.error_report =		dn_short_error_report,
 	.output =		dn_short_output,
 	.connected_output =	dn_short_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 /*
@@ -86,7 +84,6 @@ static const struct neigh_ops dn_phase3_ops = {
 	.error_report =		dn_short_error_report, /* Can use short version here */
 	.output =		dn_phase3_output,
 	.connected_output =	dn_phase3_output,
-	.queue_xmit =		dev_queue_xmit
 };
 
 static u32 dn_neigh_hash(const void *pkey,
@@ -212,7 +209,7 @@ static int dn_neigh_output_packet(struct sk_buff *skb)
 	dn_dn2eth(mac_addr, rt->rt_local_src);
 	if (dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha,
 			    mac_addr, skb->len) >= 0)
-		return neigh->ops->queue_xmit(skb);
+		return dev_queue_xmit(skb);
 
 	if (net_ratelimit())
 		printk(KERN_DEBUG "dn_neigh_output_packet: oops, can't send packet\n");
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index f5f0aa1..8a21403 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -138,7 +138,6 @@ static const struct neigh_ops arp_generic_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_connected_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 static const struct neigh_ops arp_hh_ops = {
@@ -147,14 +146,12 @@ static const struct neigh_ops arp_hh_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_resolve_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 static const struct neigh_ops arp_direct_ops = {
 	.family =		AF_INET,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 static const struct neigh_ops arp_broken_ops = {
@@ -163,7 +160,6 @@ static const struct neigh_ops arp_broken_ops = {
 	.error_report =		arp_error_report,
 	.output =		neigh_compat_output,
 	.connected_output =	neigh_compat_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 struct neigh_table arp_tbl = {
@@ -254,7 +250,7 @@ static int arp_constructor(struct neighbour *neigh)
 	if (!dev->header_ops) {
 		neigh->nud_state = NUD_NOARP;
 		neigh->ops = &arp_direct_ops;
-		neigh->output = neigh->ops->queue_xmit;
+		neigh->output = dev_queue_xmit;
 	} else {
 		/* Good devices (checked by reading texts, but only Ethernet is
 		   tested)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index db782d2..482b970 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -107,7 +107,6 @@ static const struct neigh_ops ndisc_generic_ops = {
 	.error_report =		ndisc_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_connected_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 static const struct neigh_ops ndisc_hh_ops = {
@@ -116,7 +115,6 @@ static const struct neigh_ops ndisc_hh_ops = {
 	.error_report =		ndisc_error_report,
 	.output =		neigh_resolve_output,
 	.connected_output =	neigh_resolve_output,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 
@@ -124,7 +122,6 @@ static const struct neigh_ops ndisc_direct_ops = {
 	.family =		AF_INET6,
 	.output =		dev_queue_xmit,
 	.connected_output =	dev_queue_xmit,
-	.queue_xmit =		dev_queue_xmit,
 };
 
 struct neigh_table nd_tbl = {
@@ -389,7 +386,7 @@ static int ndisc_constructor(struct neighbour *neigh)
 	if (!dev->header_ops) {
 		neigh->nud_state = NUD_NOARP;
 		neigh->ops = &ndisc_direct_ops;
-		neigh->output = neigh->ops->queue_xmit;
+		neigh->output = dev_queue_xmit;
 	} else {
 		if (is_multicast) {
 			neigh->nud_state = NUD_NOARP;
-- 
1.7.6


^ permalink raw reply related

* Re: [PATCH] net: add 802.1ad / 802.1ah / QinQ ethertypes
From: David Miller @ 2011-07-17 19:33 UTC (permalink / raw)
  To: equinox; +Cc: netdev
In-Reply-To: <1310927532-3429374-1-git-send-email-equinox@diac24.net>

From: David Lamparter <equinox@diac24.net>
Date: Sun, 17 Jul 2011 20:32:12 +0200

> define ETH_P_8021AD to 88a8 (assigned by IEEE) and add ETH_P_QINQ{1,2,3}
> for the pre-standard 9{1,2,3}00 types. all of them use 802.1q frame
> format, with 1 bit used differently in some cases.
> 
> also define ETH_P_8021AH to 88e7 (assigned by IEEE). this is Mac-in-Mac
> and uses a different, 16-byte header.
> 
> Signed-off-by: David Lamparter <equinox@diac24.net>

Applied.

^ permalink raw reply

* [PATCHv9] vhost: experimental tx zero-copy support
From: Michael S. Tsirkin @ 2011-07-17 19:36 UTC (permalink / raw)
  To: kvm, virtualization, netdev, linux-kernel

From: Shirley Ma <mashirle@us.ibm.com>

This adds experimental zero copy support in vhost-net,
disabled by default. To enable, set the zerocopytx
module option to 1.

This patch maintains the outstanding userspace buffers in the
sequence it is delivered to vhost. The outstanding userspace buffers
will be marked as done once the lower device buffers DMA has finished.
This is monitored through last reference of kfree_skb callback. Two
buffer indices are used for this purpose.

The vhost-net device passes the userspace buffers info to lower device
skb through message control. DMA done status check and guest
notification are handled by handle_tx: in the worst case is all buffers
in the vq are in pending/done status, so we need to notify guest to
release DMA done buffers first before we get any new buffers from the
vq.

One known problem is that if the guest stops submitting
buffers, buffers might never get used until some
further action, e.g. device reset. This does not
seem to affect linux guests.

Signed-off-by: Shirley <xma@us.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

The below is what I came up with. We add the feature enabled
by default for now as there are known issues, but some
guests can benefit so there's value in putting this
in tree, to help the code get wider testing.

 drivers/vhost/net.c   |   73 +++++++++++++++++++++++++++++++++++++++++-
 drivers/vhost/vhost.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/vhost/vhost.h |   29 +++++++++++++++++
 3 files changed, 186 insertions(+), 1 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index e224a92..226ca6b 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -12,6 +12,7 @@
 #include <linux/virtio_net.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
 #include <linux/rcupdate.h>
@@ -28,10 +29,18 @@
 
 #include "vhost.h"
 
+static int zcopytx;
+module_param(zcopytx, int, 0444);
+MODULE_PARM_DESC(lnksts, "Enable Zero Copy Transmit");
+
 /* Max number of bytes transferred before requeueing the job.
  * Using this limit prevents one virtqueue from starving others. */
 #define VHOST_NET_WEIGHT 0x80000
 
+/* MAX number of TX used buffers for outstanding zerocopy */
+#define VHOST_MAX_PEND 128
+#define VHOST_GOODCOPY_LEN 256
+
 enum {
 	VHOST_NET_VQ_RX = 0,
 	VHOST_NET_VQ_TX = 1,
@@ -54,6 +63,11 @@ struct vhost_net {
 	enum vhost_net_poll_state tx_poll_state;
 };
 
+static bool vhost_sock_zcopy(struct socket *sock)
+{
+	return unlikely(zcopytx) && sock_flag(sock->sk, SOCK_ZEROCOPY);
+}
+
 /* Pop first len bytes from iovec. Return number of segments used. */
 static int move_iovec_hdr(struct iovec *from, struct iovec *to,
 			  size_t len, int iov_count)
@@ -129,6 +143,8 @@ static void handle_tx(struct vhost_net *net)
 	int err, wmem;
 	size_t hdr_size;
 	struct socket *sock;
+	struct vhost_ubuf_ref *uninitialized_var(ubufs);
+	bool zcopy;
 
 	/* TODO: check that we are running from vhost_worker? */
 	sock = rcu_dereference_check(vq->private_data, 1);
@@ -149,8 +165,13 @@ static void handle_tx(struct vhost_net *net)
 	if (wmem < sock->sk->sk_sndbuf / 2)
 		tx_poll_stop(net);
 	hdr_size = vq->vhost_hlen;
+	zcopy = vhost_sock_zcopy(sock);
 
 	for (;;) {
+		/* Release DMAs done buffers first */
+		if (zcopy)
+			vhost_zerocopy_signal_used(vq);
+
 		head = vhost_get_vq_desc(&net->dev, vq, vq->iov,
 					 ARRAY_SIZE(vq->iov),
 					 &out, &in,
@@ -166,6 +187,12 @@ static void handle_tx(struct vhost_net *net)
 				set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
 				break;
 			}
+			/* If more outstanding DMAs, queue the work */
+			if (vq->upend_idx - vq->done_idx > VHOST_MAX_PEND) {
+				tx_poll_start(net, sock);
+				set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
+				break;
+			}
 			if (unlikely(vhost_enable_notify(&net->dev, vq))) {
 				vhost_disable_notify(&net->dev, vq);
 				continue;
@@ -188,9 +215,39 @@ static void handle_tx(struct vhost_net *net)
 			       iov_length(vq->hdr, s), hdr_size);
 			break;
 		}
+		/* use msg_control to pass vhost zerocopy ubuf info to skb */
+		if (zcopy) {
+			vq->heads[vq->upend_idx].id = head;
+			if (len < VHOST_GOODCOPY_LEN) {
+				/* copy don't need to wait for DMA done */
+				vq->heads[vq->upend_idx].len =
+							VHOST_DMA_DONE_LEN;
+				msg.msg_control = NULL;
+				msg.msg_controllen = 0;
+				ubufs = NULL;
+			} else {
+				struct ubuf_info *ubuf = &vq->ubuf_info[head];
+
+				vq->heads[vq->upend_idx].len = len;
+				ubuf->callback = vhost_zerocopy_callback;
+				ubuf->arg = vq->ubufs;
+				ubuf->desc = vq->upend_idx;
+				msg.msg_control = ubuf;
+				msg.msg_controllen = sizeof(ubuf);
+				ubufs = vq->ubufs;
+				kref_get(&ubufs->kref);
+			}
+			vq->upend_idx = (vq->upend_idx + 1) % UIO_MAXIOV;
+		}
 		/* TODO: Check specific error and bomb out unless ENOBUFS? */
 		err = sock->ops->sendmsg(NULL, sock, &msg, len);
 		if (unlikely(err < 0)) {
+			if (zcopy) {
+				if (ubufs)
+					vhost_ubuf_put(ubufs);
+				vq->upend_idx = ((unsigned)vq->upend_idx - 1) %
+					UIO_MAXIOV;
+			}
 			vhost_discard_vq_desc(vq, 1);
 			tx_poll_start(net, sock);
 			break;
@@ -198,7 +255,8 @@ static void handle_tx(struct vhost_net *net)
 		if (err != len)
 			pr_debug("Truncated TX packet: "
 				 " len %d != %zd\n", err, len);
-		vhost_add_used_and_signal(&net->dev, vq, head, 0);
+		if (!zcopy)
+			vhost_add_used_and_signal(&net->dev, vq, head, 0);
 		total_len += len;
 		if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
 			vhost_poll_queue(&vq->poll);
@@ -603,6 +661,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 {
 	struct socket *sock, *oldsock;
 	struct vhost_virtqueue *vq;
+	struct vhost_ubuf_ref *ubufs, *oldubufs = NULL;
 	int r;
 
 	mutex_lock(&n->dev.mutex);
@@ -632,6 +691,13 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 	oldsock = rcu_dereference_protected(vq->private_data,
 					    lockdep_is_held(&vq->mutex));
 	if (sock != oldsock) {
+		ubufs = vhost_ubuf_alloc(vq, sock && vhost_sock_zcopy(sock));
+		if (IS_ERR(ubufs)) {
+			r = PTR_ERR(ubufs);
+			goto err_ubufs;
+		}
+		oldubufs = vq->ubufs;
+		vq->ubufs = ubufs;
 		vhost_net_disable_vq(n, vq);
 		rcu_assign_pointer(vq->private_data, sock);
 		vhost_net_enable_vq(n, vq);
@@ -639,6 +705,9 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 
 	mutex_unlock(&vq->mutex);
 
+	if (oldubufs)
+		vhost_ubuf_put_and_wait(oldubufs);
+
 	if (oldsock) {
 		vhost_net_flush_vq(n, index);
 		fput(oldsock->file);
@@ -647,6 +716,8 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 	mutex_unlock(&n->dev.mutex);
 	return 0;
 
+err_ubufs:
+	fput(sock->file);
 err_vq:
 	mutex_unlock(&vq->mutex);
 err:
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ea966b3..2ebf6fc 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -179,6 +179,9 @@ static void vhost_vq_reset(struct vhost_dev *dev,
 	vq->call_ctx = NULL;
 	vq->call = NULL;
 	vq->log_ctx = NULL;
+	vq->upend_idx = 0;
+	vq->done_idx = 0;
+	vq->ubufs = NULL;
 }
 
 static int vhost_worker(void *data)
@@ -237,6 +240,8 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev)
 					  GFP_KERNEL);
 		dev->vqs[i].heads = kmalloc(sizeof *dev->vqs[i].heads *
 					    UIO_MAXIOV, GFP_KERNEL);
+		dev->vqs[i].ubuf_info = kmalloc(sizeof *dev->vqs[i].ubuf_info *
+					    UIO_MAXIOV, GFP_KERNEL);
 
 		if (!dev->vqs[i].indirect || !dev->vqs[i].log ||
 			!dev->vqs[i].heads)
@@ -249,6 +254,7 @@ err_nomem:
 		kfree(dev->vqs[i].indirect);
 		kfree(dev->vqs[i].log);
 		kfree(dev->vqs[i].heads);
+		kfree(dev->vqs[i].ubuf_info);
 	}
 	return -ENOMEM;
 }
@@ -390,6 +396,29 @@ long vhost_dev_reset_owner(struct vhost_dev *dev)
 	return 0;
 }
 
+/* In case of DMA done not in order in lower device driver for some reason.
+ * upend_idx is used to track end of used idx, done_idx is used to track head
+ * of used idx. Once lower device DMA done contiguously, we will signal KVM
+ * guest used idx.
+ */
+int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq)
+{
+	int i, j = 0;
+
+	for (i = vq->done_idx; i != vq->upend_idx; i = (i + 1) % UIO_MAXIOV) {
+		if ((vq->heads[i].len == VHOST_DMA_DONE_LEN)) {
+			vq->heads[i].len = VHOST_DMA_CLEAR_LEN;
+			vhost_add_used_and_signal(vq->dev, vq,
+						  vq->heads[i].id, 0);
+			++j;
+		} else
+			break;
+	}
+	if (j)
+		vq->done_idx = i;
+	return j;
+}
+
 /* Caller should have device mutex */
 void vhost_dev_cleanup(struct vhost_dev *dev)
 {
@@ -400,6 +429,13 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
 			vhost_poll_stop(&dev->vqs[i].poll);
 			vhost_poll_flush(&dev->vqs[i].poll);
 		}
+		/* Wait for all lower device DMAs done. */
+		if (dev->vqs[i].ubufs)
+			vhost_ubuf_put_and_wait(dev->vqs[i].ubufs);
+
+		/* Signal guest as appropriate. */
+		vhost_zerocopy_signal_used(&dev->vqs[i]);
+
 		if (dev->vqs[i].error_ctx)
 			eventfd_ctx_put(dev->vqs[i].error_ctx);
 		if (dev->vqs[i].error)
@@ -1486,3 +1522,52 @@ void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
 			       &vq->used->flags, r);
 	}
 }
+
+static void vhost_zerocopy_done_signal(struct kref *kref)
+{
+	struct vhost_ubuf_ref *ubufs = container_of(kref, struct vhost_ubuf_ref,
+						    kref);
+	wake_up(&ubufs->wait);
+}
+
+struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *vq,
+					bool zcopy)
+{
+	struct vhost_ubuf_ref *ubufs;
+	/* No zero copy backend? Nothing to count. */
+	if (!zcopy)
+		return NULL;
+	ubufs = kmalloc(sizeof *ubufs, GFP_KERNEL);
+	if (!ubufs)
+		return ERR_PTR(-ENOMEM);
+	kref_init(&ubufs->kref);
+	kref_get(&ubufs->kref);
+	init_waitqueue_head(&ubufs->wait);
+	ubufs->vq = vq;
+	return ubufs;
+}
+
+void vhost_ubuf_put(struct vhost_ubuf_ref *ubufs)
+{
+	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
+}
+
+void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
+{
+	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
+	wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
+	kfree(ubufs);
+}
+
+void vhost_zerocopy_callback(void *arg)
+{
+	struct ubuf_info *ubuf = (struct ubuf_info *)arg;
+	struct vhost_ubuf_ref *ubufs;
+	struct vhost_virtqueue *vq;
+
+	ubufs = ubuf->arg;
+	vq = ubufs->vq;
+	/* set len = 1 to mark this desc buffers done DMA */
+	vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN;
+	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
+}
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 8e03379..e287145 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -13,6 +13,11 @@
 #include <linux/virtio_ring.h>
 #include <asm/atomic.h>
 
+/* This is for zerocopy, used buffer len is set to 1 when lower device DMA
+ * done */
+#define VHOST_DMA_DONE_LEN	1
+#define VHOST_DMA_CLEAR_LEN	0
+
 struct vhost_device;
 
 struct vhost_work;
@@ -50,6 +55,18 @@ struct vhost_log {
 	u64 len;
 };
 
+struct vhost_virtqueue;
+
+struct vhost_ubuf_ref {
+	struct kref kref;
+	wait_queue_t wait;
+	struct vhost_virtqueue *vq;
+};
+
+struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *, bool zcopy);
+void vhost_ubuf_put(struct vhost_ubuf_ref *);
+void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *);
+
 /* The virtqueue structure describes a queue attached to a device. */
 struct vhost_virtqueue {
 	struct vhost_dev *dev;
@@ -114,6 +131,16 @@ struct vhost_virtqueue {
 	/* Log write descriptors */
 	void __user *log_base;
 	struct vhost_log *log;
+	/* vhost zerocopy support fields below: */
+	/* last used idx for outstanding DMA zerocopy buffers */
+	int upend_idx;
+	/* first used idx for DMA done zerocopy buffers */
+	int done_idx;
+	/* an array of userspace buffers info */
+	struct ubuf_info *ubuf_info;
+	/* Reference counting for outstanding ubufs.
+	 * Protected by vq mutex. Writers must also take device mutex. */
+	struct vhost_ubuf_ref *ubufs;
 };
 
 struct vhost_dev {
@@ -160,6 +187,8 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
 
 int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
 		    unsigned int log_num, u64 len);
+void vhost_zerocopy_callback(void *arg);
+int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq);
 
 #define vq_err(vq, fmt, ...) do {                                  \
 		pr_debug(pr_fmt(fmt), ##__VA_ARGS__);       \
-- 
1.7.5.53.gc233e

^ permalink raw reply related

* Re: [PATCH] net: vlan, qlcnic: make vlan_find_dev private
From: David Miller @ 2011-07-17 19:33 UTC (permalink / raw)
  To: equinox; +Cc: netdev, kaber, amit.salecha, anirban.chakraborty, linux-driver
In-Reply-To: <1310928792-3436326-1-git-send-email-equinox@diac24.net>

From: David Lamparter <equinox@diac24.net>
Date: Sun, 17 Jul 2011 20:53:12 +0200

> there is only one user of vlan_find_dev outside of the actual vlan code:
> qlcnic uses it to iterate over some VLANs it knows.
> 
> let's just make vlan_find_dev private to the VLAN code and have the
> iteration in qlcnic be a bit more direct. (a few rcu dereferences less
> too)
> 
> Signed-off-by: David Lamparter <equinox@diac24.net>

Applied.

^ permalink raw reply

* Re: [patch net-next-2.6] vlan: introduce ndo_vlan_[enable/disable]
From: Jiri Pirko @ 2011-07-17 19:44 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: netdev, davem, shemminger, eric.dumazet, greearb
In-Reply-To: <CAHXqBFL1s30DxxHk-1wEy1q48LvgbO+w4zXkOm0sAU61XONoVw@mail.gmail.com>

Sun, Jul 17, 2011 at 10:36:04AM CEST, mirqus@gmail.com wrote:
>W dniu 17 lipca 2011 09:30 użytkownik Jiri Pirko <jpirko@redhat.com> napisał:
>> Sat, Jul 16, 2011 at 04:14:36PM CEST, mirqus@gmail.com wrote:
>>>2011/7/16 Jiri Pirko <jpirko@redhat.com>:
>>>> Some devices are not able to enable/disable rx/tw vlan accel separately.
>>>> they depend on ndo_vlan_rx_register to know if to enable of disable
>>>> hw accel. And since ndo_vlan_rx_register is going to die soon,
>>>> this must be resolved.
>>>>
>>>> One solution might be to enable accel on device start every time, even
>>>> if there are no vlan up on. But this would change behaviour and might
>>>> lead to possible regression (on older devices).
>>>[...]
>>>
>>>Please describe the possible regression. As I see it, there won't be
>>>any user visible change of behaviour - network code takes care of
>>>reinserting VLAN tag when necessary. If you think that disabling tag
>>>stripping is beneficial for cases where no VLANs are configured, it's
>>>better to do that in netdev_fix_features() for devices which advertise
>>>NETIF_F_HW_VLAN_RX in hw_features.
>>
>> Well I just wanted to preserve current behaviour which is that in many
>> drivers vlan accel is enabled only if some vid is registered upon the
>> device and it's disabled again when no vid is registered. I can see
>> no way to do this with current code after removing ndo_vlan_rx_register.
>>
>> I expect unexpected
>
>:-D
>
>> ... problems on old cards when vlan accel would be
>> enabled all the time, but maybe I'm wrong...
>
>Device has no way of knowing how the system uses VLAN tags, stripped
>or not. Any problems would be driver problems and since you're making
>it all use generic code, bugs will hit all drivers simultaneously or
>(preferably) won't happen at all.
>
>> One idea is for device which do not support sepatate rx/tx vlan accel
>> enabling/disabling they can probably use ndo_fix_features force to
>> enable/disable rx/tx pair together. That would resolve the situation as
>> well giving user possibility to turn off vlan accel in case of any issues.
>
>That is exactly the idea behind ndo_fix_features.

In netdev_fix_features add check if either one of NETIF_F_HW_VLAN_TX or
NETIF_F_HW_VLAN_RX is set and in that case set the other one. Of course
this would be done only for devices what do not support separate rx/tx
vlan on/off. But how to distinguish? NETIF_F_HW_VLAN_BOTH feature flag?

Thanks.

Jirka

>
>Best Regards,
>Michał Mirosław

^ permalink raw reply

* Re: [PATCH 0/3] ath6kl: neatening
From: Joe Perches @ 2011-07-17 19:52 UTC (permalink / raw)
  To: Kalle Valo; +Cc: devel, gregkh, error27, linux-kernel, linux-wireless, netdev
In-Reply-To: <4E23307B.4060504@qca.qualcomm.com>

On Sun, 2011-07-17 at 21:56 +0300, Kalle Valo wrote:
> On 07/17/2011 09:43 PM, Joe Perches wrote:
> > Joe Perches (3):
> >   ath6kl: Add missing newlines and coalesce messages
> >   ath6kl: Remove __func__ uses from ath6kl_err
> >   ath6kl: cfg80211: Add and use ath6kl_cfg80211_ready helper
> Nice, thanks a lot. I'm planning to send v3 of athk6kl patches later
> today. Is it okay for you if I amend your three patches to that patchset?

'course.

^ permalink raw reply

* Re: [PATCHv9] vhost: experimental tx zero-copy support
From: David Miller @ 2011-07-17 19:53 UTC (permalink / raw)
  To: mst; +Cc: kvm, virtualization, netdev, linux-kernel
In-Reply-To: <20110717193540.GA29392@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Sun, 17 Jul 2011 22:36:14 +0300

> The below is what I came up with. We add the feature enabled
> by default ...

s/enabled/disabled/  Well, at least you got it right in the
commit message where it counts :-)

^ permalink raw reply

* Re: [PATCHv9] vhost: experimental tx zero-copy support
From: Jesper Juhl @ 2011-07-17 20:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: kvm, virtualization, netdev, linux-kernel
In-Reply-To: <20110717193540.GA29392@redhat.com>

On Sun, 17 Jul 2011, Michael S. Tsirkin wrote:

> From: Shirley Ma <mashirle@us.ibm.com>
> 
> This adds experimental zero copy support in vhost-net,
> disabled by default. To enable, set the zerocopytx
> module option to 1.
> 
> This patch maintains the outstanding userspace buffers in the
> sequence it is delivered to vhost. The outstanding userspace buffers
> will be marked as done once the lower device buffers DMA has finished.
> This is monitored through last reference of kfree_skb callback. Two
> buffer indices are used for this purpose.
> 
> The vhost-net device passes the userspace buffers info to lower device
> skb through message control. DMA done status check and guest
> notification are handled by handle_tx: in the worst case is all buffers
> in the vq are in pending/done status, so we need to notify guest to
> release DMA done buffers first before we get any new buffers from the
> vq.
> 
> One known problem is that if the guest stops submitting
> buffers, buffers might never get used until some
> further action, e.g. device reset. This does not
> seem to affect linux guests.
> 
> Signed-off-by: Shirley <xma@us.ibm.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> The below is what I came up with. We add the feature enabled
> by default for now as there are known issues, 

You mean "disabled" - right?


> but some
> guests can benefit so there's value in putting this
> in tree, to help the code get wider testing.
> 
>  drivers/vhost/net.c   |   73 +++++++++++++++++++++++++++++++++++++++++-
>  drivers/vhost/vhost.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/vhost/vhost.h |   29 +++++++++++++++++
>  3 files changed, 186 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index e224a92..226ca6b 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -12,6 +12,7 @@
>  #include <linux/virtio_net.h>
>  #include <linux/miscdevice.h>
>  #include <linux/module.h>
> +#include <linux/moduleparam.h>
>  #include <linux/mutex.h>
>  #include <linux/workqueue.h>
>  #include <linux/rcupdate.h>
> @@ -28,10 +29,18 @@
>  
>  #include "vhost.h"
>  
> +static int zcopytx;
> +module_param(zcopytx, int, 0444);

Should everyone be able to read this? How about "0440" just to be 
paranoid? or?

> +MODULE_PARM_DESC(lnksts, "Enable Zero Copy Transmit");
> +
>  /* Max number of bytes transferred before requeueing the job.
>   * Using this limit prevents one virtqueue from starving others. */
>  #define VHOST_NET_WEIGHT 0x80000
>  
> +/* MAX number of TX used buffers for outstanding zerocopy */
> +#define VHOST_MAX_PEND 128
> +#define VHOST_GOODCOPY_LEN 256
> +
>  enum {
>  	VHOST_NET_VQ_RX = 0,
>  	VHOST_NET_VQ_TX = 1,
> @@ -54,6 +63,11 @@ struct vhost_net {
>  	enum vhost_net_poll_state tx_poll_state;
>  };
>  
> +static bool vhost_sock_zcopy(struct socket *sock)
> +{
> +	return unlikely(zcopytx) && sock_flag(sock->sk, SOCK_ZEROCOPY);
> +}
> +
>  /* Pop first len bytes from iovec. Return number of segments used. */
>  static int move_iovec_hdr(struct iovec *from, struct iovec *to,
>  			  size_t len, int iov_count)
> @@ -129,6 +143,8 @@ static void handle_tx(struct vhost_net *net)
>  	int err, wmem;
>  	size_t hdr_size;
>  	struct socket *sock;
> +	struct vhost_ubuf_ref *uninitialized_var(ubufs);
> +	bool zcopy;
>  
>  	/* TODO: check that we are running from vhost_worker? */
>  	sock = rcu_dereference_check(vq->private_data, 1);
> @@ -149,8 +165,13 @@ static void handle_tx(struct vhost_net *net)
>  	if (wmem < sock->sk->sk_sndbuf / 2)
>  		tx_poll_stop(net);
>  	hdr_size = vq->vhost_hlen;
> +	zcopy = vhost_sock_zcopy(sock);
>  
>  	for (;;) {
> +		/* Release DMAs done buffers first */
> +		if (zcopy)
> +			vhost_zerocopy_signal_used(vq);
> +
>  		head = vhost_get_vq_desc(&net->dev, vq, vq->iov,
>  					 ARRAY_SIZE(vq->iov),
>  					 &out, &in,
> @@ -166,6 +187,12 @@ static void handle_tx(struct vhost_net *net)
>  				set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
>  				break;
>  			}
> +			/* If more outstanding DMAs, queue the work */
> +			if (vq->upend_idx - vq->done_idx > VHOST_MAX_PEND) {
> +				tx_poll_start(net, sock);
> +				set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
> +				break;
> +			}
>  			if (unlikely(vhost_enable_notify(&net->dev, vq))) {
>  				vhost_disable_notify(&net->dev, vq);
>  				continue;
> @@ -188,9 +215,39 @@ static void handle_tx(struct vhost_net *net)
>  			       iov_length(vq->hdr, s), hdr_size);
>  			break;
>  		}
> +		/* use msg_control to pass vhost zerocopy ubuf info to skb */
> +		if (zcopy) {
> +			vq->heads[vq->upend_idx].id = head;
> +			if (len < VHOST_GOODCOPY_LEN) {
> +				/* copy don't need to wait for DMA done */
> +				vq->heads[vq->upend_idx].len =
> +							VHOST_DMA_DONE_LEN;
> +				msg.msg_control = NULL;
> +				msg.msg_controllen = 0;
> +				ubufs = NULL;
> +			} else {
> +				struct ubuf_info *ubuf = &vq->ubuf_info[head];
> +
> +				vq->heads[vq->upend_idx].len = len;
> +				ubuf->callback = vhost_zerocopy_callback;
> +				ubuf->arg = vq->ubufs;
> +				ubuf->desc = vq->upend_idx;
> +				msg.msg_control = ubuf;
> +				msg.msg_controllen = sizeof(ubuf);
> +				ubufs = vq->ubufs;
> +				kref_get(&ubufs->kref);
> +			}
> +			vq->upend_idx = (vq->upend_idx + 1) % UIO_MAXIOV;
> +		}
>  		/* TODO: Check specific error and bomb out unless ENOBUFS? */
>  		err = sock->ops->sendmsg(NULL, sock, &msg, len);
>  		if (unlikely(err < 0)) {
> +			if (zcopy) {
> +				if (ubufs)
> +					vhost_ubuf_put(ubufs);
> +				vq->upend_idx = ((unsigned)vq->upend_idx - 1) %
> +					UIO_MAXIOV;
> +			}
>  			vhost_discard_vq_desc(vq, 1);
>  			tx_poll_start(net, sock);
>  			break;
> @@ -198,7 +255,8 @@ static void handle_tx(struct vhost_net *net)
>  		if (err != len)
>  			pr_debug("Truncated TX packet: "
>  				 " len %d != %zd\n", err, len);
> -		vhost_add_used_and_signal(&net->dev, vq, head, 0);
> +		if (!zcopy)
> +			vhost_add_used_and_signal(&net->dev, vq, head, 0);
>  		total_len += len;
>  		if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
>  			vhost_poll_queue(&vq->poll);
> @@ -603,6 +661,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
>  {
>  	struct socket *sock, *oldsock;
>  	struct vhost_virtqueue *vq;
> +	struct vhost_ubuf_ref *ubufs, *oldubufs = NULL;
>  	int r;
>  
>  	mutex_lock(&n->dev.mutex);
> @@ -632,6 +691,13 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
>  	oldsock = rcu_dereference_protected(vq->private_data,
>  					    lockdep_is_held(&vq->mutex));
>  	if (sock != oldsock) {
> +		ubufs = vhost_ubuf_alloc(vq, sock && vhost_sock_zcopy(sock));
> +		if (IS_ERR(ubufs)) {
> +			r = PTR_ERR(ubufs);
> +			goto err_ubufs;
> +		}
> +		oldubufs = vq->ubufs;
> +		vq->ubufs = ubufs;
>  		vhost_net_disable_vq(n, vq);
>  		rcu_assign_pointer(vq->private_data, sock);
>  		vhost_net_enable_vq(n, vq);
> @@ -639,6 +705,9 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
>  
>  	mutex_unlock(&vq->mutex);
>  
> +	if (oldubufs)
> +		vhost_ubuf_put_and_wait(oldubufs);
> +
>  	if (oldsock) {
>  		vhost_net_flush_vq(n, index);
>  		fput(oldsock->file);
> @@ -647,6 +716,8 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
>  	mutex_unlock(&n->dev.mutex);
>  	return 0;
>  
> +err_ubufs:
> +	fput(sock->file);
>  err_vq:
>  	mutex_unlock(&vq->mutex);
>  err:
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index ea966b3..2ebf6fc 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -179,6 +179,9 @@ static void vhost_vq_reset(struct vhost_dev *dev,
>  	vq->call_ctx = NULL;
>  	vq->call = NULL;
>  	vq->log_ctx = NULL;
> +	vq->upend_idx = 0;
> +	vq->done_idx = 0;
> +	vq->ubufs = NULL;
>  }
>  
>  static int vhost_worker(void *data)
> @@ -237,6 +240,8 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev)
>  					  GFP_KERNEL);
>  		dev->vqs[i].heads = kmalloc(sizeof *dev->vqs[i].heads *
>  					    UIO_MAXIOV, GFP_KERNEL);
> +		dev->vqs[i].ubuf_info = kmalloc(sizeof *dev->vqs[i].ubuf_info *
> +					    UIO_MAXIOV, GFP_KERNEL);
>  
>  		if (!dev->vqs[i].indirect || !dev->vqs[i].log ||
>  			!dev->vqs[i].heads)
> @@ -249,6 +254,7 @@ err_nomem:
>  		kfree(dev->vqs[i].indirect);
>  		kfree(dev->vqs[i].log);
>  		kfree(dev->vqs[i].heads);
> +		kfree(dev->vqs[i].ubuf_info);
>  	}
>  	return -ENOMEM;
>  }
> @@ -390,6 +396,29 @@ long vhost_dev_reset_owner(struct vhost_dev *dev)
>  	return 0;
>  }
>  
> +/* In case of DMA done not in order in lower device driver for some reason.
> + * upend_idx is used to track end of used idx, done_idx is used to track head
> + * of used idx. Once lower device DMA done contiguously, we will signal KVM
> + * guest used idx.
> + */
> +int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq)
> +{
> +	int i, j = 0;

On two lines?
        int i;
        int j = 0;
as per CodingStyle..

> +
> +	for (i = vq->done_idx; i != vq->upend_idx; i = (i + 1) % UIO_MAXIOV) {
> +		if ((vq->heads[i].len == VHOST_DMA_DONE_LEN)) {
> +			vq->heads[i].len = VHOST_DMA_CLEAR_LEN;
> +			vhost_add_used_and_signal(vq->dev, vq,
> +						  vq->heads[i].id, 0);
> +			++j;
> +		} else
> +			break;
> +	}
> +	if (j)
> +		vq->done_idx = i;
> +	return j;
> +}
> +
>  /* Caller should have device mutex */
>  void vhost_dev_cleanup(struct vhost_dev *dev)
>  {
> @@ -400,6 +429,13 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
>  			vhost_poll_stop(&dev->vqs[i].poll);
>  			vhost_poll_flush(&dev->vqs[i].poll);
>  		}
> +		/* Wait for all lower device DMAs done. */
> +		if (dev->vqs[i].ubufs)
> +			vhost_ubuf_put_and_wait(dev->vqs[i].ubufs);
> +
> +		/* Signal guest as appropriate. */
> +		vhost_zerocopy_signal_used(&dev->vqs[i]);
> +
>  		if (dev->vqs[i].error_ctx)
>  			eventfd_ctx_put(dev->vqs[i].error_ctx);
>  		if (dev->vqs[i].error)
> @@ -1486,3 +1522,52 @@ void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
>  			       &vq->used->flags, r);
>  	}
>  }
> +
> +static void vhost_zerocopy_done_signal(struct kref *kref)
> +{
> +	struct vhost_ubuf_ref *ubufs = container_of(kref, struct vhost_ubuf_ref,
> +						    kref);
> +	wake_up(&ubufs->wait);
> +}
> +
> +struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *vq,
> +					bool zcopy)
> +{
> +	struct vhost_ubuf_ref *ubufs;
> +	/* No zero copy backend? Nothing to count. */
> +	if (!zcopy)
> +		return NULL;
> +	ubufs = kmalloc(sizeof *ubufs, GFP_KERNEL);
> +	if (!ubufs)
> +		return ERR_PTR(-ENOMEM);
> +	kref_init(&ubufs->kref);
> +	kref_get(&ubufs->kref);
> +	init_waitqueue_head(&ubufs->wait);
> +	ubufs->vq = vq;
> +	return ubufs;
> +}
> +
> +void vhost_ubuf_put(struct vhost_ubuf_ref *ubufs)
> +{
> +	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
> +}
> +
> +void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
> +{
> +	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
> +	wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
> +	kfree(ubufs);
> +}
> +
> +void vhost_zerocopy_callback(void *arg)
> +{
> +	struct ubuf_info *ubuf = (struct ubuf_info *)arg;

No need to explicitly cast a void*, just do:

     struct ubuf_info *ubuf = arg;


> +	struct vhost_ubuf_ref *ubufs;
> +	struct vhost_virtqueue *vq;
> +
> +	ubufs = ubuf->arg;
> +	vq = ubufs->vq;

Why not shorten this a bit as:

     struct vhost_ubuf_ref *ubufs = ubuf->arg;
     struct vhost_virtqueue *vq = ubufs->vq;

?

> +	/* set len = 1 to mark this desc buffers done DMA */
> +	vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN;
> +	kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 
> +}
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index 8e03379..e287145 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -13,6 +13,11 @@
>  #include <linux/virtio_ring.h>
>  #include <asm/atomic.h>
>  
> +/* This is for zerocopy, used buffer len is set to 1 when lower device DMA
> + * done */
> +#define VHOST_DMA_DONE_LEN	1
> +#define VHOST_DMA_CLEAR_LEN	0
> +
>  struct vhost_device;
>  
>  struct vhost_work;
> @@ -50,6 +55,18 @@ struct vhost_log {
>  	u64 len;
>  };
>  
> +struct vhost_virtqueue;
> +
> +struct vhost_ubuf_ref {
> +	struct kref kref;
> +	wait_queue_t wait;
> +	struct vhost_virtqueue *vq;
> +};
> +
> +struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *, bool zcopy);
> +void vhost_ubuf_put(struct vhost_ubuf_ref *);
> +void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *);
> +
>  /* The virtqueue structure describes a queue attached to a device. */
>  struct vhost_virtqueue {
>  	struct vhost_dev *dev;
> @@ -114,6 +131,16 @@ struct vhost_virtqueue {
>  	/* Log write descriptors */
>  	void __user *log_base;
>  	struct vhost_log *log;
> +	/* vhost zerocopy support fields below: */
> +	/* last used idx for outstanding DMA zerocopy buffers */
> +	int upend_idx;
> +	/* first used idx for DMA done zerocopy buffers */
> +	int done_idx;
> +	/* an array of userspace buffers info */
> +	struct ubuf_info *ubuf_info;
> +	/* Reference counting for outstanding ubufs.
> +	 * Protected by vq mutex. Writers must also take device mutex. */
> +	struct vhost_ubuf_ref *ubufs;
>  };
>  
>  struct vhost_dev {
> @@ -160,6 +187,8 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
>  
>  int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
>  		    unsigned int log_num, u64 len);
> +void vhost_zerocopy_callback(void *arg);
> +int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq);
>  
>  #define vq_err(vq, fmt, ...) do {                                  \
>  		pr_debug(pr_fmt(fmt), ##__VA_ARGS__);       \
> 

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply

* Re: [PATCH 0/3] ath6kl: neatening
From: Kalle Valo @ 2011-07-17 20:45 UTC (permalink / raw)
  To: Joe Perches; +Cc: devel, gregkh, error27, linux-kernel, linux-wireless, netdev
In-Reply-To: <1310932335.2286.8.camel@Joe-Laptop>

On 07/17/2011 10:52 PM, Joe Perches wrote:
> On Sun, 2011-07-17 at 21:56 +0300, Kalle Valo wrote:
>> On 07/17/2011 09:43 PM, Joe Perches wrote:
>>> Joe Perches (3):
>>>   ath6kl: Add missing newlines and coalesce messages
>>>   ath6kl: Remove __func__ uses from ath6kl_err
>>>   ath6kl: cfg80211: Add and use ath6kl_cfg80211_ready helper
>> Nice, thanks a lot. I'm planning to send v3 of athk6kl patches later
>> today. Is it okay for you if I amend your three patches to that patchset?
> 
> 'course.

Great, thanks. I have now applied your patches to ath6kl-cleanup tree
and they will be included in patchset v3.

Kalle

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox