From patchwork Mon Sep 14 16:12:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 33593 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id A554DB7BBF for ; Tue, 15 Sep 2009 03:01:11 +1000 (EST) Received: by ozlabs.org (Postfix) id 8F16FDDD04; Tue, 15 Sep 2009 03:01:11 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 0CB63DDD01 for ; Tue, 15 Sep 2009 03:00:20 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753030AbZINQNn (ORCPT ); Mon, 14 Sep 2009 12:13:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752045AbZINQNm (ORCPT ); Mon, 14 Sep 2009 12:13:42 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:43163 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbZINQNl (ORCPT ); Mon, 14 Sep 2009 12:13:41 -0400 Received: from nehalam (pool-71-117-243-208.ptldor.fios.verizon.net [71.117.243.208]) (authenticated bits=0) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n8EGD22b019435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 14 Sep 2009 09:13:06 -0700 Date: Mon, 14 Sep 2009 09:12:55 -0700 From: Stephen Hemminger To: Mike McCormack , David Miller Cc: netdev@vger.kernel.org Subject: [PATCH alt] sky2: transmit ring accounting Message-ID: <20090914091255.2cda7d24@nehalam> In-Reply-To: <4AAD7B3D.7010403@ring3k.org> References: <4AAD7B3D.7010403@ring3k.org> Organization: Linux Foundation X-Mailer: Claws Mail 3.6.1 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, hits=-4.358 required=5 tests=AWL, BAYES_00, FH_HOST_EQ_VERIZON_P, OSDL_HEADER_SUBJECT_BRACKETED, RDNS_DYNAMIC X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Be more accurate about number of transmit list elements required. Signed-off-by: Stephen Hemminger --- Note: this is an optimization, the old code guaranteed more space than necessary (MAX_SKB_TX_LE was always bigger than needed). -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/net/sky2.c 2009-09-14 08:45:55.730729606 -0700 +++ b/drivers/net/sky2.c 2009-09-14 09:09:42.395712810 -0700 @@ -65,8 +65,8 @@ #define RX_DEF_PENDING RX_MAX_PENDING /* This is the worst case number of transmit list elements for a single skb: - VLAN + TSO + CKSUM + Data + skb_frags * DMA */ -#define MAX_SKB_TX_LE (4 + (sizeof(dma_addr_t)/sizeof(u32))*MAX_SKB_FRAGS) + VLAN:GSO + CKSUM + Data + skb_frags * DMA */ +#define MAX_SKB_TX_LE (2 + (sizeof(dma_addr_t)/sizeof(u32))*(MAX_SKB_FRAGS+1)) #define TX_MIN_PENDING (MAX_SKB_TX_LE+1) #define TX_MAX_PENDING 4096 #define TX_DEF_PENDING 127 @@ -1567,11 +1567,13 @@ static unsigned tx_le_req(const struct s { unsigned count; - count = sizeof(dma_addr_t) / sizeof(u32); - count += skb_shinfo(skb)->nr_frags * count; + count = (skb_shinfo(skb)->nr_frags + 1) + * (sizeof(dma_addr_t) / sizeof(u32)); if (skb_is_gso(skb)) ++count; + else if (sizeof(dma_addr_t) == sizeof(u32)) + ++count; /* possible vlan */ if (skb->ip_summed == CHECKSUM_PARTIAL) ++count;